Hello i was just adding some functions to my gamemdoe and i noticed every time i call
pl:StripWeapons() it CRASHES my gamemode
heres the whole function
function GM:PlayerLoadOut( pl )
pl:StripWeapons()
end
any help or hints are very appreciated!
[highlight](User was banned for this post ("Wrong section" - mahalis))[/highlight]
I saw someone saying in another thread:
[quote]It's ply, not pl[/quote]
I'm totally noob in Lua, so I don't know ;x
[QUOTE=Cyberuben;27353716]I saw someone saying in another thread:
I'm totally noob in Lua, so I don't know ;x[/QUOTE]
that is funny
anyway looks like your doing everything right but we need more code
Well heres it
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
// Serverside only stuff goes here
/*---------------------------------------------------------
Name: gamemode:PlayerLoadout( )
Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/
function GM:PlayerLoadOut( pl )
pl:StripWeapons()
pl:Give( "empty_weapon" )
end
function GM:OnNPCKilled( victim, killer, weapon)
local RandomNumber= math.random(1,5)
local SpawnHight = 124
local NpcPos = victim:GetPos()
if RandomNumber == 1 then
local Drop = ents.Create("weapon_scar")
Drop:SetPos(NpcPos+Vector(0,0,SpawnHight))
Drop:Spawn()
Drop:Activate()
elseif RandomNumber == 2 then
local Drop = ents.Create("weapon_p90")
Drop:SetPos(NpcPos+Vector(0,0,SpawnHight))
Drop:Spawn()
Drop:Activate()
elseif RandomNumber == 3 then
local Drop = ents.Create("Commando")
Drop:SetPos(NpcPos+Vector(0,0,SpawnHight))
Drop:Spawn()
Drop:Activate()
end
end
And the gamemode works fine with pl:StripWeapons() removed right?
even deleting GM:PlayerLoadout function and letting only the second one(the npc thing)
it crashes! maybe should i add on my shared.lua DeriveGamemode( "sandbox" ) ?
pl:StripWeapons() might call GAMEMODE.PlayerLoadout
No promises whether or not it does, but that would make sense.
mmmm i find one more problem if i load the gamemode it crash if i load it again it crashes but if i load it a THIRD time it works
this is a too messy!!!!!!!!!!!
[QUOTE=Cyberuben;27353716]I saw someone saying in another thread:
I'm totally noob in Lua, so I don't know ;x[/QUOTE]
it doesnt matter if you use pl or ply its the same
nvm if i save the file using notepad++ or oter editor it works fine if i save it using notepad it dont works
[QUOTE=flayne;27410580]it doesnt matter if you use pl or ply its the same[/QUOTE]
Actually, it does matter. It's whatever you put in the function arguments (the parentheses).
You could put retard and call retard:StripWeapons() and it would be the same thing.
Sorry, you need to Log In to post a reply to this thread.