Jump to content

Need Help with arrest Command


Senze

Recommended Posts

Hey Guys i have i big problem with the arrest command I scripting a Rl Server

here are the Lines:

function Arrest(Spieler, Befehl, Mitspieler)
local team = getPlayerTeam(Spieler)
local name = getPlayerFromName(Mitspieler)
 
if team == lspd then
if PlayerToPoint(Spieler, 3, 268, 77, 1001) then
local element = getElementType(name)
 
if element == "player" then
local player = getPlayerName(element) 
local level = getPlayerWantedLevel(element)
 
if level > 0 then
setElementInterior(player, 6, 265, 77, 1002)
else
outputChatBox("Dieser Spieler ist nicht gesucht", Spieler)
end
else
outputDebugString("Es befindet sich ein Fehler in der Abfrage Element")
end
else
outputChatBox("Du befindest dich nicht im PD.", Spieler)
end
else
outputChatBox("Du bst kein Polizist.", Spieler)
end
end
addCommandHandler("arrest", Arrest)

i need some help plz =(

Link to comment

the arrest player won't move in to the Jail

and in the serverconsole will come this:

[13:57:13] WARNING: Hauptscript.lua: Bad argument @ 'getPlayerName' - Line: 501

[13:57:13] WARNING: Hauptscript.lua: Bad argument @ 'setPlayerWantedLevel' - Lin

e: 502

and nothing is happen =( need relly help =(

Link to comment

Change:

if element == "player" then  
local player = getPlayerName(element)    
local level = getPlayerWantedLevel(element)

To:

if element == "player" then  
local player = getPlayerName(Spieler)    
local level = getPlayerWantedLevel(Spieler)

Your getting an bad argument because your trying to get things from "element"

Wich isnt a variable.

Link to comment

No offense, but... this is rubbish.

1) A player element is returned by getPlayerFromName (in this case.) and is completely separate from the player's nick. You can get a name from an element and an element from a name, but you can NOT use them interchangeably - if a function wants an element and you give it a string (name, etc,) there will be trouble.

2) You can't get the player name of a string. (Which is returned by getElementType)

3) You once again can't expect Lua to read your mind. "name" doesn't exist or is defined some place where it makes very little sense.

Sorry, but this is useless. Re-read http://robhol.net/guide/basics and then start over from scratch, this is sadly not going to help you do anything.

Pay special attention to how elements are just that: ELEMENTS, not player names or other strings.

You might also want to revisit some basic Lua. I'm not sure if you defined the lspd variable anywhere, but if you didn't (and don't see immediately why that is a problem,) that suggests you should pick up a good Lua tutorial before even thinking about anything MTA-related.

Link to comment
function Arrest(Spieler, Befehl, Mitspieler)
local team = getPlayerTeam(Spieler)
local name = getPlayerFromName(Mitspieler)
if team == lspd then 
if PlayerToPoint(Spieler, 3, 268, 77, 1001) then 
-- this part is unnecessary: local element = getElementType(name) 
if name then  --this should do 
local player = getPlayerName(name)  -- 'element' to 'name' 
local level = getPlayerWantedLevel(name)  --'element' to 'name'
if level > 0 then
setElementInterior(player, 6, 265, 77, 1002)
else
outputChatBox("Dieser Spieler ist nicht gesucht", Spieler)
end
else
outputDebugString("Es befindet sich ein Fehler in der Abfrage Element")
end
else
outputChatBox("Du befindest dich nicht im PD.", Spieler)
end
else
outputChatBox("Du bst kein Polizist.", Spieler )
end 
end
addCommandHandler("arrest", Arrest)

hope it will work ;)

Link to comment

won't work =(

so ca some one post me the command plz this will realy help me a lot.

EDIT://

so ive got it now :D

function Arrest(Spieler, Befehl, Mitspieler)
local team = getPlayerTeam(Spieler)
local name = getPlayerFromName(Mitspieler)
 
if team == lspd then 
if PlayerToPoint(Spieler, 3, 268, 77, 1001) then 
local player = getPlayerName(name)  -- 'element' to 'name' 
local level = getPlayerWantedLevel(name)  --'element' to 'name'
 
if level > 0 then
 
setElementInterior(name, 6)
setElementPosition(name, 265, 77, 1002)
else
outputChatBox("Dieser Spieler ist nicht gesucht", Spieler)
end
else
outputChatBox("Du befindest dich nicht im PD.", Spieler)
end
else
outputChatBox("Du bst kein Polizist.", Spieler )
end 
end
addCommandHandler("arrest", Arrest)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...