ID:672118
 
(See the best response by DarkCampainger.)
Code:
        Give_Levels_To_world()
set category = "Admin"
if(GMLockCheck())
usr<<"<font face ='Palatino Linotype' color=red>Your Admin Powers Are Locked."
return
switch(alert("Give levels to every player logged in?","","Yes","No"))
if("Yes")
var/amount=input("How many")as num
for(var/mob/PC/M in world)
if(!M.client)continue
if(!M.loggedin)continue
M << "[usr] gave you [amount] levels. Be patient while they add to your stats."
M.levelgains = 0
while(amount>0)
M.exp = M.tnl
M.Level_Up()
amount -= 1
sleep(1)
world<<"<b><font face ='Palatino Linotype' color=red>[usr] has given everyone Levels!</b>"
else
return


Problem description:I want so that when i click on this verb.. everyone in the server should should get levels but it doesnt work..

Shaoni wrote:
>                         if(!M.client)continue
> if(!M.loggedin)continue
>

So basically, people only get levels if they're not logged in and NPCs? I think you want the opposite.

>                         if(M.client)continue
> if(M.loggedin)continue
>


You obviously don't know what continue does. It doesn't continue the code, it skips the code and goes straight to the next iteration.

To the OP, try being more general with your for() loop.
for(var/mob/m)
if(m.loggedin && m.client)
// Do everything else here
Best response
It's subtracting out of the same amount variable for all players, so only the first player will get any levels.

If there's something else wrong with it, it would help if you described which parts aren't working (ie do the alerts/inputs at least come up? Does at least one player gain a level? ect)
it gives levels to the first player only
yes alerts come up
it comes up like this
for the first player-
Mystic gave you 100 levels. Be patient while they add to your stats.

for other players -
Mystic gave you 0 levels. Be patient while they add to your stats.