My armor script is giving armor to everyone in the server?
11 replies, posted
Hey everyone, I made this tiny script on DarkRP so that when you become SWAT, you have 100 armor, but apparently, every team get's armor.
Here's my code snippet if you want to see:
[lua]if t ~= TEAM_SWAT then
ply:SetArmor(100)
end[/lua]
I'm a bit new to Lua, so any help would be great!
Use ==
[lua]
if t == TEAM_SWAT then
ply:SetArmor(100)
end
[/lua]
this says
if t equals team_swat then give them 100 armor.
[QUOTE=SharpCoder;35307107]Use ==
[lua]
if t == TEAM_SWAT then
ply:SetArmor(100)
end
[/lua]
this says
if t equals team_swat then give them 100 armor.[/QUOTE]
Hmmm, I'm trying this and it doesn't work, SWAT doesn't get armor and the jobs get's broken
[QUOTE=Greatie;35307189]Hmmm, I'm trying this and it doesn't work, SWAT doesn't get armor and the jobs get's broken[/QUOTE]
what is "t"? can you post some more code about where you are getting the variable. Also - what error do you get? The change I made shouldn't have had such an effect...
if my limited coding knowledge is right, you had the symbol as does not equal instead of equal.
SharpCoder's change should have worked if the previous code worked.
[QUOTE=SharpCoder;35307219]what is "t"? can you post some more code about where you are getting the variable. Also - what error do you get? The change I made shouldn't have had such an effect...[/QUOTE]
Whoops - Scratch that, the job's works again, but you don't get any armor when you become the SWAT job.
"t" is "Team" for DarkRP
[QUOTE=Greatie;35307338]Whoops - Scratch that, the job's works again, but you don't get any armor when you become the SWAT job.
"t" is "Team" for DarkRP[/QUOTE]
Yeah I wanted to make sure t was actually representing the team and not used for something else =P Anyway, make sure you add the code snippet [I]after[/I] the player has officially changed teams. I would guess your code is being run before the team switch occurs which would explain why the SWAT doesn't get Armor.
[QUOTE=SharpCoder;35307375]Yeah I wanted to make sure t was actually representing the team and not used for something else =P Anyway, make sure you add the code snippet [I]after[/I] the player has officially changed teams. I would guess your code is being run before the team switch occurs which would explain why the SWAT doesn't get Armor.[/QUOTE]
To add to this, most gamemode hooks represent an event or point in time. For example, PlayerInitialSpawn represents when the player spawns for the first time that game session, PlayerSpawn represents any spawn, Think represents 1/10th of a second... You get the picture.
By the way, I'm putting this code into the GM:PlayerLoadout function, that is correct, right?
[QUOTE=Bel Irkalli;35307487]To add to this, most gamemode hooks represent an event or point in time. For example, PlayerInitialSpawn represents when the player spawns for the first time that game session, PlayerSpawn represents any spawn, Think represents 1/10th of a second... You get the picture.[/QUOTE]
Ahh yeah I guess I was under the impression this was going to be used when someone [I]becomes[/I] swat. In light of this realization, you're right, a hook would be far more useful.
@Greatie - I think the PlayerLoadout should be a good place to add that. Are you saying you don't get armor when you become swat or when you respawn as swat? Or both?
[QUOTE=Greatie;35307501]By the way, I'm putting this code into the GM:PlayerLoadout function, that is correct, right?[/QUOTE]
As long as PlayerLoadout event is triggered when you change classes, then yes. Put some ErrorNoHalts in there to test all your logic and shit; or to see if it's even being called.
[QUOTE=SharpCoder;35307796]@Greatie - I think the PlayerLoadout should be a good place to add that. Are you saying you don't get armor when you become swat or when you respawn as swat? Or both?[/QUOTE]
Both. I kinda had this idea to block every team expect SWAT to get armor.... a messy way of doing this, but might work.
Sorry, you need to Log In to post a reply to this thread.