So, I have made an end round Deathrun pointshop reward, which rewards the winning team with 100 points. (If a player is a Donor, on the winning team, all of whom which is a Donor will receive 200 instead.) I was wondering, since I am very new to coding Lua, if the following code would work correctly as described?
[CODE]
if SERVER then
hook.Add( "OnRoundSet", "Round Set", function( round, winner )
if round == ROUND_ENDING then
print( "The winner is "..winner.."! They will receive 100 points!" )
winner:PS_GivePoints( "100" )
if ( winner:IsUserGroup( "donor", "moderator" ) ) then
print( "Since "..winner.." is a Donor, they will receive 200 points instead!" )
winner:PS_GivePoints( "200" )
end
end
end )
return
end
[/CODE]
You should test code yourself instead of asking Facepunch, then come back if you have any errors
I don't really know how this version of Deathrun works, but is winner considered a player? I'm asking as you've used winner there, but ply when checking user groups
[QUOTE=NiandraLades;46768409]You should test code yourself instead of asking Facepunch, then come back if you have any errors
I don't really know how this version of Deathrun works, but is winner considered a player? I'm asking as you've used winner there, but ply when checking user groups[/QUOTE]
Winner is not, in fact, considered a player. I guess it's pretty dumb to put player. I'm changing it to winner. To answer the first question, I don't have any Donors, and the only Moderator I have as of right now is offline. It's 1 A.M. here.
Connect to your dev server using a second gmod client after setting the server to sv_lan 1 and enabling multi load on gmod.
The SteamID for the second client will be STEAM_0:0:0 - make that player whichever rank you want while testing.
[url]http://facepunch.com/showthread.php?t=1411111&p=46746129&viewfull=1#post46746129[/url]
Sorry, you need to Log In to post a reply to this thread.