Sign in to follow this  
Andres99907

My code doesn't work :(

Recommended Posts

Posted (edited)

I'm trying to make a resource that obtain the name of a player like this line:

local who = getPlayerName(playerSource), playerSource(who)

but :( i got this

GetPlayerName  [expected element at argument 1, got nil]

lua:13: attempt to call global 'playerSource' (a nil value)

 

I need help :'c

 

the script is of the type server

Edited by Andres99907

Share this post


Link to post
Posted (edited)

function check ( player, seat, jacked )
if getElementData(source, "policeman") then
if getElementData(source, "owner") == getAccountName(getPlayerAccount(player)) then
else
cancelEvent()
outputChatBox("You need to be a Policeman", player)
end
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), check )

function setcop(player, cmd, who)
local who = getPlayerName(playersource), setcop(who)
local co = getPedOccupiedVehicle(who)
setElementData(co, "policeman", true)
setElementData(co, "owner", getPlayerName(who))
outputChatBox("The Policeman:"..getPlayerName(who), player)
end

addEventHandler ( "onVehicleEnter", getRootElement(), setcop )

i made a few changes

Edited by Andres99907

Share this post


Link to post
Posted (edited)
function check ( player, seat, jacked )
if getElementData(source, "policeman") ==  true then
if getElementData(source, "owner") == getAccountName(getPlayerAccount(player)) then
else
cancelEvent()
outputChatBox("You need to be a Policeman", player)
end
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), check )

function setcop(player, cmd)
setElementData(getPedOccupiedVehicle(player), "policeman", true)
setElementData(getPedOccupiedVehicle(player), "owner", getAccountName(getPlayerAccount(player)))
outputChatBox("The Policeman:"..getPlayerName(player), player)
end

addEventHandler ( "onVehicleEnter", getRootElement(), setcop )

 

Edited by Sendy
  • Like 1

Share this post


Link to post

Note ; use onVehicleStartEnter insted of onVehicleEnter

Because onVehicleEnter can't be cancelled

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.