LonelyRoad Posted June 20, 2010 Share Posted June 20, 2010 Hey guys, So I'm new to scripting and I've been trying to make my own / admin commands. I've come down to the part where I'm using "setElementPosition" and "getElementPosition" so I've written this: --ADMIN TELEPORTS --Goto function adminGoto(sourcePlayer, command, tPlayer) if isGuestAccount(getPlayerAccount(sourcePlayer)) ~= true then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(sourcePlayer)), aclGetGroup("Admin")) then outputChatBox ( "Sorry, but you are not allowed to use the goto command", sourcePlayer ) return false else if not tPlayer then outputChatBox("You need to specify a target player. Syntax: /agoto ", sourcePlayer) return false else if not getPlayerFromName(tPlayer) then outputChatBox("Specified player not found on server.", sourcePlayer) return false else local targetPlayer = getPlayerFromName(tPlayer) local tx, ty, tz = getElementPosition(tPlayer) if isPedInVehicle(targetPlayer) then local vehicle = getPedOccupiedVehicle(tPlayer) local seats = getVehicleMaxPassengers ( vehicle ) + 1 local i = 0 while i < seats do if not getVehicleOccupant (vehicle, i) then warpPedIntoVehicle (sourcePlayer, vehicle, i) break end i = i + 1 end if i >= seats then setElementPosition(sourcePlayer, tx + 10, ty, tz + 25, true) outputChatBox("Sorry, the player's vehicle is full.", sourcePlayer) end else setElementPosition(sourcePlayer, tx + 10, ty, tz + 25, true) outputChatBox("You have been teleported to:" ..getPlayerFromName(tPlayer)..".", sourcePlayer) outputChatBox("An administrator has teleported to you.", targetPlayer) -- etc end end end end end end addCommandHandler("agoto", adminGoto) --Bring function adminBring(sourcePlayer, command, tPlayer) if isGuestAccount(getPlayerAccount(sourcePlayer)) ~= true then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(sourcePlayer)), aclGetGroup("Admin")) then outputChatBox ( "Sorry, but you are not allowed to use the bring command", sourcePlayer ) return false else local targetPlayer = getPlayerFromName(tPlayer) local tx, ty, tz = getElementPosition(sourcePlayer) setElementPosition(targetPlayer, tx + 10, ty, tz + 25, true) outputChatBox("You have teleported " ..getPlayerName(targetPlayer).." to you.", sourcePlayer) outputChatBox("An administrator has teleported you to them.", targetPlayer) end end end addCommandHandler("abring", adminBring) So, here's the errors that are printed by each command: agoto: [20:39:35] WARNING: admincmds/server/admincommands.lua:17: Bad argument @ 'getPlayerFromName' [20:39:35] WARNING: admincmds/server/admincommands.lua:18: Bad argument @ 'getElementPosition' [20:39:35] WARNING: admincmds/server/admincommands.lua:19: Bad argument @ 'isPedInVehicle' [20:39:35] WARNING: admincmds/server/admincommands.lua:35: Bad argument @ 'setElementPosition' [20:39:35] WARNING: admincmds/server/admincommands.lua:36: Bad argument @ 'getPlayerName' [20:39:35] ERROR: admincmds/server/admincommands.lua:36: attempt to concatenate a boolean value abring: [20:41:31] WARNING: admincmds/server/admincommands.lua:53: Bad argument @ 'getPlayerFromName'[20:41:31] WARNING: admincmds/server/admincommands.lua:55: Bad argument @ 'setElementPosition' [20:41:31] WARNING: admincmds/server/admincommands.lua:56: Bad argument @ 'getPlayerName' [20:41:31] ERROR: admincmds/server/admincommands.lua:56: attempt to concatenate a boolean value I'd normally ask my friend, but I just can't see what's wrong myself and he's AFK lol. Hope someone can help. EDIT: Corrected line numbers to fit snippet and not the full resource file. Link to comment
dzek (varez) Posted June 20, 2010 Share Posted June 20, 2010 -- 17 and 18 line: local targetPlayer = getPlayerFromName(tPlayer) -- before this try outputChatBox(tostring(tPlayer)) -- a little debug local tx, ty, tz = getElementPosition(tPlayer) -- you should use player element (targetPlayer) not player name ;P -- this occurs in few next lines in bring function you are not checking if player name is passed at all.. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now