• Spawn protection script. Mystical error
    3 replies, posted
I have a script: [CODE]function notify( ply, msg, cvar ) ply:SendLua("GAMEMODE:AddNotify(\"" .. msg .. "\", " .. tostring(cvar) .. ", 5)") end function FalseGodMode( ply, dmginfo ) if(ply:GetNetworkedVar("pSpawN") == 1) then dmginfo:ScaleDamage( 0 ) end end hook.Add("EntityTakeDamage", "FalseGodMode", FalseGodMode) function SpawNNoWeapons(ply) if(ply:GetNetworkedVar("pSpawN") == 1) then return false end end hook.Add("PlayerCanPickupWeapon", "SpawN_SpawNNoWeapons", SpawNNoWeapons) hook.Add("PlayerSpawnSWEP", "SpawN_SpawNNoWeaponsA", SpawNNoWeapons) hook.Add("PlayerGiveSWEP", "SpawN_SpawNNoWeaponsB", SpawNNoWeapons) function SpawNGetTime( v, _, args ) if( time < 0 or not time ) then time = 15 end if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then time = tonumber(args[1]) end return time end concommand.Add( "spawn_ptime", SpawNGetTime ) function SpawNGhostGetTime( v, _, args ) if( ghostTime < 0 or not ghostTime ) then ghostTime = 10 end if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then ghostTime = tonumber(args[1]) end if(ply:GetNetworkedVar("reSpawNing") == 1) then return ghostTime else return 0 end end concommand.Add( "spawn_ghost_time", SpawNGhostGetTime ) function SpawNOnOff( v, _, args ) if( not active ) then active = false end if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then if(tonumber(args[1]) >= 1) then active = false else active = true end end return !active end concommand.Add( "spawn_disable", SpawNOnOff ) function SpawNGhost( v, _, args ) if( not onoff ) then onoff = false end if( args[1] != 1 ) then args[1] = 0 else args[1] = 1 end if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then onoff = tonumber(args[1]) end if(ply:GetNetworkedVar("reSpawNing") == 1) then return onoff else return false end end concommand.Add( "spawn_ghost", SpawNGhost ) function SpawNPos( v, _, args ) if( not reset ) then reset = false end if( args[1] != 1 ) then args[1] = 0 else args[1] = 1 end if( ( IsValid(v) and ( v:IsAdmin() or v:IsSuperAdmin() ) ) or ( not IsValid(v) ) ) then reset = tonumber(args[1]) end return reset end concommand.Add( "spawn_reset_pos", SpawNPos ) function spawn( ply ) if( SpawNOnOff() and ( ( SpawNGetTime() != 0 ) or ( SpawNGhostGetTime() != 0 ) ) ) then ply:Freeze( true ) savedPos = ply:GetPos() timer.Simple( 1, function() ply:Freeze( false ) ply:SetNetworkedVar("pSpawN", 1) ply:StripWeapons() if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_DEBRIS) end -- ply:GodEnable() -- if(SpawNGhost()) then rdrInvis( ply, true, 100 ) else rdrInvis( ply, true, 0 ) end if( SpawNGetTime() != 0 ) then notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" ) else if( SpawNGhostGetTime() != 0 ) notify( ply, "[SpawN] You are now a ghost!", "NOTIFY_GENERIC" ) end end) if(ply:UserID()) then if(SpawNGhost()) then val = SpawNGetTime() else val = SpawNGhostGetTime() end timer.Create(tostring(ply:UserID()) .. "_SpawnMe", val+1, 1, function() if(ply and IsValid(ply)) then rdrInvis( ply, false, 255 ) ply:SetNetworkedVar("pSpawN", 0) if(SpawNGhost()) then ply:SetCollisionGroup(COLLISION_GROUP_PLAYER) end -- ply:GodDisable() -- if(SpawNGhost() or SpawNPos()) then ply:SetPos(savedPos) end ply:SetNetworkedVar("reSpawNing", 0) --Now for the loadout-- GAMEMODE:PlayerLoadout( ply ) if( SpawNGetTime() != 0 ) then notify( ply, "[SpawN] You are protected!", "NOTIFY_GENERIC" ) else if( SpawNGhostGetTime() != 0 ) notify( ply, "[SpawN] You are no longer a ghost!", "NOTIFY_GENERIC" ) end end end) else ply:Kick("UserID Error.") end end end hook.Add( "PlayerSpawn", "spawn", spawn ) function fixSpawn( ply ) if( ply and IsValid(ply) ) then ply:SetNetworkedVar("reSpawNing", 1) end if( ply:UserID() and timer.Exists(tostring(ply:UserID()) .. "_SpawnMe") ) then timer.Destroy(tostring(ply:UserID()) .. "_SpawnMe") end end hook.Add( "DoPlayerDeath", "fixSpawn", fixSpawn ) [/CODE] Console said me: [CODE] [ERROR] addons/spawnprotect/lua/autorun/spawnprotection.lua:123: 'then' expected near 'notify' 1. unknown - addons/spawnprotect/lua/autorun/spawnprotection.lua:0 [/CODE] I cant understand what is wrong. Poke me nose in error :3
It's not a mystical error, in-fact it's very clear. On line 123 it's expecting then. Without then everything else in the document is be part of the if statement's condition. Change: [lua]else if( SpawNGhostGetTime() != 0 )[/lua] to [lua]elseif( SpawNGhostGetTime() != 0 ) then[/lua] [editline]1st May 2014[/editline] also what the fuck [QUOTE=Dezigl;44697760] Poke me nose in error :3[/QUOTE]
That's it I am changing to labpunch, I was ninja'd by 7 blimmin minutes.
[QUOTE=rbreslow;44697905]also what the fuck[/QUOTE] Oh, i think its only russian term. I dont know how to describe. Its like indicate an error, but in the form of cute. How to take the cat by the scruff and poke his nose, if you understood. :) [editline]1st May 2014[/editline] [QUOTE=rbreslow;44697905]It's not a mystical error, in-fact it's very clear. On line 123 it's expecting then. Without then everything else in the document is be part of the if statement's condition. [/QUOTE] I don't knowt how i didn't see it [editline]1st May 2014[/editline] thank you.
Sorry, you need to Log In to post a reply to this thread.