DrTight
29.06.2008, 22:39
Hi, ich bin derzeit an einem Plugin für Assmod dran. Erhalte aber jedes mal ein eof Fehler, den ich nicht erkenne. Ich bitte darum, das einer der mehr Ahnung in Lua hat als ich, mal über den Code zu gucken und mir zu sagen ob es so funktionieren kann.
Vielen Dank
Mfg Tight
local PLUGIN = {}
PLUGIN.Name = "Setspawn"
PLUGIN.Author = "_DrTight"
PLUGIN.Date = "29th Juni 2008"
PLUGIN.Filename = PLUGIN_FILENAME
PLUGIN.ClientSide = true
PLUGIN.ServerSide = true
PLUGIN.APIVersion = 2
PLUGIN.Gamemodes = {}
if (SERVER) then
function playerinitSpawn()
SP_PLAYER.Spawntrue = "false"
hook.Add( "PlayerInitialSpawn", "Player_InitialSpawn", playerinitSpawn );
end
function PLUGIN.Setspawn( PLAYER, CMD, ARGS )
if (PLAYER:IsTempAdmin()) then
local SP_PLAYER = ASS_FindPlayer(ARGS[1])
if (!SP_PLAYER) then
ASS_MessagePlayer(PLAYER, "Player not found!\n")
return
end
if (SP_PLAYER != PLAYER) then
if (SP_PLAYER:IsBetterOrSame(PLAYER)) then
// disallow!
ASS_MessagePlayer(PLAYER, "Access denied! \"" .. PL_SETSPAWN:Nick() .. "\" has same or better access then you.")
return
end
end
if (ASS_RunPluginFunction( "AllowPlayerSetspawn", true, PLAYER, SP_PLAYER )) then
// Actually Sets Players Spawn
function SP_PLAYER:Setspawn()
local trace = PLAYER:GetEyeTrace()
local hitpos = trace.HitPos
SP_PLAYER.pos = hitpos + Vector( 0, 0, 32 )
SP_PLAYER.Spawntrue = "true"
ASS_MessagePlayer(PLAYER, "Set \"" .. SP_PLAYER:Nick() .. "\" new Spawn Position.")
end
else
// Player doesn't have enough access.
ASS_MessagePlayer( PLAYER, "Access Denied!\n")
end
function Checkplayerspawn(SP_PLAYER)
if SP_PLAYER.Spawntrue == "true" then
SP_PLAYER.SpawnPlayer(SP_PLAYER)
end
hook.Add("PlayerSpawn","NewSpawn",Checkplayerspawn)
function SpawnPlayer(SP_PLAYER)
SP_PLAYER:SetPos( SP_PLAYER.pos )
SP_PLAYER:PrintMessage( HUD_PRINTTALK, "Spawning at New Spawnpoint" )
SP_PLAYER:EmitSound("ambient/machines/teleport1.wav",300,100)
end
concommand.Add("ASS_Setspawn", PLUGIN.Setspawn)
if (CLIENT) then
function PLUGIN.Setspawn(PLAYER)
// Pretty simple. All we do is fire off a console command.
if (!PLAYER:IsValid()) then return end
RunConsoleCommand( "ASS_Setspawn", PLAYER:UniqueID() )
end
function PLUGIN.BuildMenu(NEWMENU)
ASS_PlayerMenu( NEWMENU, {"IncludeLocalPlayer", "IncludeAll"}, PLUGIN.Setspawn )
end
function PLUGIN.AddMenu(DMENU)
DMENU:AddSubMenu( "Setspawn" , nil, PLUGIN.BuildMenu)
end
end
ASS_RegisterPlugin(PLUGIN)
Vielen Dank
Mfg Tight
local PLUGIN = {}
PLUGIN.Name = "Setspawn"
PLUGIN.Author = "_DrTight"
PLUGIN.Date = "29th Juni 2008"
PLUGIN.Filename = PLUGIN_FILENAME
PLUGIN.ClientSide = true
PLUGIN.ServerSide = true
PLUGIN.APIVersion = 2
PLUGIN.Gamemodes = {}
if (SERVER) then
function playerinitSpawn()
SP_PLAYER.Spawntrue = "false"
hook.Add( "PlayerInitialSpawn", "Player_InitialSpawn", playerinitSpawn );
end
function PLUGIN.Setspawn( PLAYER, CMD, ARGS )
if (PLAYER:IsTempAdmin()) then
local SP_PLAYER = ASS_FindPlayer(ARGS[1])
if (!SP_PLAYER) then
ASS_MessagePlayer(PLAYER, "Player not found!\n")
return
end
if (SP_PLAYER != PLAYER) then
if (SP_PLAYER:IsBetterOrSame(PLAYER)) then
// disallow!
ASS_MessagePlayer(PLAYER, "Access denied! \"" .. PL_SETSPAWN:Nick() .. "\" has same or better access then you.")
return
end
end
if (ASS_RunPluginFunction( "AllowPlayerSetspawn", true, PLAYER, SP_PLAYER )) then
// Actually Sets Players Spawn
function SP_PLAYER:Setspawn()
local trace = PLAYER:GetEyeTrace()
local hitpos = trace.HitPos
SP_PLAYER.pos = hitpos + Vector( 0, 0, 32 )
SP_PLAYER.Spawntrue = "true"
ASS_MessagePlayer(PLAYER, "Set \"" .. SP_PLAYER:Nick() .. "\" new Spawn Position.")
end
else
// Player doesn't have enough access.
ASS_MessagePlayer( PLAYER, "Access Denied!\n")
end
function Checkplayerspawn(SP_PLAYER)
if SP_PLAYER.Spawntrue == "true" then
SP_PLAYER.SpawnPlayer(SP_PLAYER)
end
hook.Add("PlayerSpawn","NewSpawn",Checkplayerspawn)
function SpawnPlayer(SP_PLAYER)
SP_PLAYER:SetPos( SP_PLAYER.pos )
SP_PLAYER:PrintMessage( HUD_PRINTTALK, "Spawning at New Spawnpoint" )
SP_PLAYER:EmitSound("ambient/machines/teleport1.wav",300,100)
end
concommand.Add("ASS_Setspawn", PLUGIN.Setspawn)
if (CLIENT) then
function PLUGIN.Setspawn(PLAYER)
// Pretty simple. All we do is fire off a console command.
if (!PLAYER:IsValid()) then return end
RunConsoleCommand( "ASS_Setspawn", PLAYER:UniqueID() )
end
function PLUGIN.BuildMenu(NEWMENU)
ASS_PlayerMenu( NEWMENU, {"IncludeLocalPlayer", "IncludeAll"}, PLUGIN.Setspawn )
end
function PLUGIN.AddMenu(DMENU)
DMENU:AddSubMenu( "Setspawn" , nil, PLUGIN.BuildMenu)
end
end
ASS_RegisterPlugin(PLUGIN)