• How would I change the deaths weapons?
    12 replies, posted
Hello, I am wanting to change the weapons of the deaths for my deathrun server using Mr.Gash's deathrun gamemode. I have tried some fixes that I have found in other threads on facepunch but they didn't seem to work. Here is a function that I have tried: [CODE]hook.Add( "PlayerLoadout", "WeaponLoadout", function( _p ) if ( _p:Team( ) == TEAM_DEATH ) then _p:Give( "weapon_rubyrose_scythe" ); end end );[/CODE] I put the code above in my init.lua file and it didn't work. Any help would be appreciated guys!
Are you sure that _p:Team() returns TEAM_DEATH? As in TTT those are just roles and using :Team() would not return the value you have. Look through where the teams are created to verify this. It's likely that the gamemode creator created a check such as IsDeath() or something of the sort to help with this
[QUOTE=MGCLegend;47843871]Are you sure that _p:Team() returns TEAM_DEATH? As in TTT those are just roles and using :Team() would not return the value you have. Look through where the teams are created to verify this. It's likely that the gamemode creator created a check such as IsDeath() or something of the sort to help with this[/QUOTE] I looked around some of the gamemode files and didn't see any IsDeath() type of deal. I even tried that in the code like this: [code] hook.Add( "PlayerLoadout", "WeaponLoadout", function( _p ) if ( _p:IsDeath() == true ) then _p:Give( "weapon_rubyrose_scythe" ); end end ); [/code] and that didn't work.
I didn't mean look solely for that. Look for team.SetUp() and see what the team name is
[QUOTE=MGCLegend;47843951]I didn't mean look solely for that. Look for team.SetUp() and see what the team name is[/QUOTE] Sorry I'm new to lua so I'm still trying to figure out how all of this works but I did manage to find: [code]TEAM_DEATH = 2 team.SetUp( TEAM_DEATH, "Death", Color( 180, 60, 60, 255 ), false ) team.SetSpawnPoint( TEAM_DEATH, "info_player_terrorist" )[/code] How would this work in the other function?
[QUOTE=trippymodzhq;47843976]Sorry I'm new to lua so I'm still trying to figure out how all of this works but I did manage to find: [code]TEAM_DEATH = 2 team.SetUp( TEAM_DEATH, "Death", Color( 180, 60, 60, 255 ), false ) team.SetSpawnPoint( TEAM_DEATH, "info_player_terrorist" )[/code] How would this work in the other function?[/QUOTE] Great. That's what I needed. So TEAM_DEATH is an index number that's returned when calling a players :Team() If you wanted it to return a string like returning "Death" you could do team.GetName( _p:Team() ) [CODE]hook.Add( "PlayerLoadout", "WeaponLoadout", function( _p ) if ( _p:Team( ) == 2) then _p:Give( "weapon_rubyrose_scythe" ); end end );[/CODE] Edit: Thanks for the dumb *later changed to funny thanks lol* sorry I am intoxicated and it took me five tries to figure out my brain was still on
[QUOTE=MGCLegend;47844021]Great. That's what I needed. So TEAM_DEATH is an index number that's returned when calling a players :Team() If you wanted it to return a string like returning "Death" you could do team.GetName( _p:Team() ) [CODE]hook.Add( "PlayerLoadout", "WeaponLoadout", function( _p ) if ( _p:Team( ) == 2) then _p:Give( "weapon_rubyrose_scythe" ); end end );[/CODE] Edit: Thanks for the dumb *later changed to funny thanks lol* sorry I am intoxicated and it took me five tries to figure out my brain was still on[/QUOTE] Okay thanks for the help! It is detecting that I am a death but I am not receiving my weapon. Just so you don't think its a problem with my swep I added I changed it to a physgun. The code below: [code]hook.Add( "PlayerLoadout", "WeaponLoadout", function( _p ) if ( _p:Team( ) == 2) then _p:Give( "weapon_physgun" ); _p:ChatPrint( "You are a death!" ) end end );[/code] Now the code above is printing in chat that I am a death. But as I said above I am not receiving my weapon...
In the Deathrun gamemode it's likely that the gamemode strips your weapons after this hook is called. Try running this inside the GM:PlayerSpawn() instead. Make sure not to remove anything inside this gamemode hook though. GM:PlayerSpawn() should be in the init.lua file. [B]WARNING!!!!! THIS FUNCTION IS ALREADY IN YOUR INIT.LUA ONLY ADD THE IF PART OF THE FUNCTION TO THE GM:PlayerSpawn(ply) FUNCTION !!!!![/B] [CODE]function GM:PlayerSpawn( ply ) if ( ply:Team( ) == 2) then ply:Give( "weapon_physgun" ); ply:ChatPrint( "You are a death!" ) end end[/CODE]
[QUOTE=MGCLegend;47844134]In the Deathrun gamemode it's likely that the gamemode strips your weapons after this hook is called. Try running this inside the GM:PlayerSpawn() instead. Make sure not to remove anything inside this gamemode hook though. GM:PlayerSpawn() should be in the init.lua file. [B]WARNING!!!!! THIS FUNCTION IS ALREADY IN YOUR INIT.LUA ONLY ADD THE IF PART OF THE FUNCTION TO THE GM:PlayerSpawn(ply) FUNCTION !!!!![/B] [CODE]function GM:PlayerSpawn( ply ) if ( ply:Team( ) == 2) then ply:Give( "weapon_physgun" ); ply:ChatPrint( "You are a death!" ) end end[/CODE][/QUOTE] Alright I tried that and still the same thing. It is printing in chat that I am a death but I am not receiving my weapon.
Bump! I still need to fix this guys!
Are you sure the entity exists?
Change [URL="https://github.com/Mr-Gash/GMod-Deathrun/blob/master/deathrun/gamemode/init.lua#L336"]this function[/URL]. Not PlayerSpawn.
[QUOTE=Lolcats;47846337]Change [URL="https://github.com/Mr-Gash/GMod-Deathrun/blob/master/deathrun/gamemode/init.lua#L336"]this function[/URL]. Not PlayerSpawn.[/QUOTE] Thanks man! That worked. Fixed.
Sorry, you need to Log In to post a reply to this thread.