0


I am having trouble stripping the weapons from players when a new round starts.

here's what i have:

function StripWeaps(p)
    while not (player(p, "weapontype") == 0) do
        local wpn = player(p, "weapontype")
        parse("strip "..p.." "..wpn)
    end
end

The code was taken in part from lee's equip replacer script. This function is called from a 'spawn' hook function. Firt of all it seem to be calling the spawn hook before the round begins, and so before the players have respawned. For some reason at the end of the round it get's stuck in the while loop and never actually strips any weapons (this is for the player that is still alive at the end). It doesn't seem to strip the weapons at the start of the first round either, but it doesn't get stuck then at least.

Any ideas why it doesn't work? Or could you shed some light on why the spawn hook is called before the startround hook?

flag offensive
asked 2010-08-16 06:32:07.969183
5
add comment
1 Answers:
0


player(n,"weapontype") behaves quite differently nowadays. The initial base condition used to terminate the loops is to check whether the player still holds a weapon. Since 0.1.1.6, CS2D automatically reequips a player with a knife if he is stripped of everything. Here's a new implementation:

for _,wpn in ipairs(playerweapons(id)) do
    parse(string.format("strip %s %s", id, wpn))
end

Hopefully, the ipairs returns a copy of the weapon table instead of a reference to the actual table.

Edit: On a side note, I never pushed out a patch of this bug for AMX2D since people used to believe that using @equip will automagically crash the server :D, but then Red realized that he can just @parse everything T_T

permanent link | flag offensive
answered 2010-08-16 15:49:18.618540
41
add comment
Your answer:
You are now not logged in but you can answer first and then login
toggle preview



Tags:

× 1
× 1
× 1

Asked: 1 year, 9 months ago

Seen: 3,009 times

Last updated: 1 year, 9 months ago

Related questions


Made with Django.