monamour Posted March 30, 2018 Share Posted March 30, 2018 am trying to make script that allows only staffs(or acl i chose) to enter such vehicles and it would be great if somone teach me how to make players pays amount of money to spawn them this is what i made but it's not working SCRIPT ERROR: carpriv\server.lua:4: ')' expected near 'then' } script: staffcar = { [432]=true,[425]=true,[520]=true,[599]=true } function enterVehicle ( player, seat, jacked ) if ( staffcar[getElementModel(source)] ) and ( not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) then cancelEvent() outputChatBox ( "only acl can enter this!", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 if ( staffcar[getElementModel(source)] ) and ( not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") )) then Or even better if you do not want to be confused: if staffcar[getElementModel(source)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) then I prefer the last one. Only wrapping code between (...) when really needed. Link to comment
monamour Posted March 30, 2018 Author Share Posted March 30, 2018 @IIYAMA Thank you bro , that is so kind of you to replay and how i could make players (non staff) pays if they wanted to spawn some of them (like 425) ? using freeroam gui Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 To be able to do that, you have to learn how to communicate between client(player his pc) and the server(can also be the player his pc or another computer). GUI = clientside. Giving weapons, take money away(synced) = serverside You need to be able to understand this, even if you run your server on your own machine: The fibreculture journal. (z.d.). Architecting Cheating in MMORPGs [Foto]. Geraadpleegd van http://sixteen.fibreculturejournal.org/files/2010/07/Figure_3.jpg This tutorial might be handy. 1 Link to comment
monamour Posted March 30, 2018 Author Share Posted March 30, 2018 5 hours ago, IIYAMA said: To be able to do that, you have to learn how to communicate between client(player his pc) and the server(can also be the player his pc or another computer). GUI = clientside. Giving weapons, take money away(synced) = serverside You need to be able to understand this, even if you run your server on your own machine: The fibreculture journal. (z.d.). Architecting Cheating in MMORPGs [Foto]. Geraadpleegd van http://sixteen.fibreculturejournal.org/files/2010/07/Figure_3.jpg This tutorial might be handy. yeah i understand the diffrence betwen server and client . freeroam has server and,client side, of course , so i need to edit the server side defently but how could i make them spawn them and able to enter them if i have staffcar script(the one you helpt me with) running in same time !! Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 (edited) By making exceptions local vehicleEnterExceptions = {} -- function if vehicleEnterExceptions[player] or (staffcar[getElementModel(source)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") )) then -- end function addPlayerToException (player) vehicleEnterExceptions[player] = true return true end function removePlayerFromException (player) vehicleEnterExceptions[player] = nil return true end addEventHandler("onPlayerQuit", root, function () removePlayerFromException (source) end) addPlayerToException (player) -- DO > https://wiki.multitheftauto.com/wiki/WarpPedIntoVehicle setTimer(removePlayerFromException, 50, 1, player) -- Events are afaik async, so must this function call. You could try something like this. (untested) Edited March 30, 2018 by IIYAMA Link to comment
monamour Posted March 30, 2018 Author Share Posted March 30, 2018 (edited) 13 hours ago, IIYAMA said: if ( staffcar[getElementModel(source)] ) and ( not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") )) then Or even better if you do not want to be confused: if staffcar[getElementModel(source)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) then I prefer the last one. Only wrapping code between (...) when really needed. btw its still not working new error : WARNING: server.lua:4: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: server.lua:4: attempt to concatenate a boolean value and the error show every time (non admin) enter Vehichle (staffcar) Edited March 30, 2018 by monamour Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 (edited) it means that the variable which should contain the player isn't containing it. If you use the event onVehicleStartEnter, use the first parameter for the player. https://wiki.multitheftauto.com/wiki/OnVehicleStartEnter Parameters: player enteringPlayer, int seat, player jacked, int door Source: The source is in this event the vehicle. Example: function enterVehicle ( player, seat, jacked ) if vehicleEnterExceptions[player] or (staffcar[getElementModel(player)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(player)), aclGetGroup ("Admin") )) then Edited March 30, 2018 by IIYAMA Link to comment
monamour Posted March 30, 2018 Author Share Posted March 30, 2018 (edited) 35 minutes ago, IIYAMA said: it means that the variable which should contain the player isn't containing it. If you use the event onVehicleStartEnter, use the first parameter for the player. https://wiki.multitheftauto.com/wiki/OnVehicleStartEnter Parameters: player enteringPlayer, int seat, player jacked, int door Source: The source is in this event the vehicle. Example: function enterVehicle ( player, seat, jacked ) if vehicleEnterExceptions[player] or (staffcar[getElementModel(player)] and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(player)), aclGetGroup ("Admin") )) then but its exactly what i did like you see in the start of topic : script: staffcar = { [432]=true,[425]=true,[520]=true,[599]=true } function enterVehicle ( player, seat, jacked ) ------- exactly like you said if ( staffcar[getElementModel(source)] ) and not isObjectInACLGroup ( "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) then cancelEvent() outputChatBox ( "only acl can enter this!", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) but what happening is even normal player can enter them and i have the error message in the console which is : WARNING: server.lua:4: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean] ERROR: server.lua:4: attempt to concatenate a boolean value *i think the problem is somewhere in the red code Edited March 30, 2018 by monamour * Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) Indeed. What was source again in this event? Spoiler Vehicle Can you get the account from a ... ? Spoiler vehicle Answer: Spoiler No What happens when you do that? Spoiler Wiki: https://wiki.multitheftauto.com/wiki/GetPlayerAccount Returns Returns the player's account object, or false if the player passed to the function is invalid. Can you get the accountname of the value false? Spoiler No So: Spoiler "user." .. getAccountName(getPlayerAccount(player)), aclGetGroup ("Admin") ) Link to comment
monamour Posted March 30, 2018 Author Share Posted March 30, 2018 6 minutes ago, IIYAMA said: "user." .. getAccountName(getPlayerAccount(source)), aclGetGroup ("Admin") ) Indeed. What was source again in this event? Hide contents Vehicle Can you get the account from a ... ? Hide contents vehicle Answer: Hide contents No What happens when you do that? Hide contents Wiki: https://wiki.multitheftauto.com/wiki/GetPlayerAccount Returns Returns the player's account object, or false if the player passed to the function is invalid. Can you get the accountname of the value false? Hide contents No So: Hide contents "user." .. getAccountName(getPlayerAccount(player)), aclGetGroup ("Admin") ) OH bro i am so stupid that i didn't realized it!! now i understand , by your favor! thank you so much , i really appreicate that you spent time to teach and correct me , not only replaying with the correct code but with explaying and its so kindly!! 1 Link to comment
Moderators IIYAMA Posted March 30, 2018 Moderators Share Posted March 30, 2018 It seems hiding content really helps to give clear information. Thank you very much too! 1 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