Andres99907 Posted March 31, 2019 Share Posted March 31, 2019 (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 March 31, 2019 by Andres99907 Link to comment
Andres99907 Posted March 31, 2019 Author Share Posted March 31, 2019 My script* but i can't change the title Link to comment
Andres99907 Posted March 31, 2019 Author Share Posted March 31, 2019 (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 March 31, 2019 by Andres99907 Link to comment
Sendy Posted March 31, 2019 Share Posted March 31, 2019 (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 March 31, 2019 by Sendy 1 Link to comment
KillerX Posted April 1, 2019 Share Posted April 1, 2019 Note ; use onVehicleStartEnter insted of onVehicleEnter Because onVehicleEnter can't be cancelled 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