Fantanic Posted December 26, 2013 Share Posted December 26, 2013 (edited) Hello , I would like to make a new collum named 'Jobs' I tried to make it already but it isnt working for some reason Im getting bad argument @ 'setElementData" [expected element at argument 1, got nil] here is the script line : setElementData(thePlayer,"Job","Job Name") Edited January 7, 2014 by Guest Link to comment
Chronic Posted December 26, 2013 Share Posted December 26, 2013 Have you defined thePlayer? Link to comment
Fantanic Posted December 26, 2013 Author Share Posted December 26, 2013 Ohw right i forgot to do that , thank you for letting me know. And its working now. Thanks Link to comment
Fantanic Posted December 26, 2013 Author Share Posted December 26, 2013 solved , ok another question how to lock a car to this elementdata? local vehicle = createVehicle(506, 2100.2697, 1397.4947, 10.3, 0, 0, 0) -- Create the vehicle setElementData(vehicle, "HLS", true, false) -- Give it element data in 'Chief' and make its value a boolean 'true' addEventHandler("onVehicleStartEnter", root, function(thePlayer, seat, jacked, door) local vehicleOwner = getElementData(source, "HLS") -- Get the vehicle's element data on 'Chief' local gangGroup = getElementData( client, "HLS", skin.name ) -- Get the entering player's element data on 'Chief' if (not vehicleOwner) then return end -- If the vehicle doesn't have such data, then cancel if (gangGroup ~= vehicleOwner) then -- If the entering player's data doesn't match the vehicle data, continue outputChatBox("This car is locked and belongs to the following class: Admins", thePlayer, 245, 20, 20, false) -- Display a warning cancelEvent() -- Prevent the player from entering the vehicle end end ) I tried this already but it doesnt work (i found this script in a other forum since i didnt know how to get it work ^) Link to comment
Chronic Posted December 26, 2013 Share Posted December 26, 2013 setVehicleLocked Good luck Link to comment
Fantanic Posted December 26, 2013 Author Share Posted December 26, 2013 setVehicleLocked Good luck Isnt the car locked already? or shouldnt it be? Link to comment
Chronic Posted December 26, 2013 Share Posted December 26, 2013 By default cars are unlocked. You can use setVehicleLocked to lock them or unlock them. Link to comment
Castillo Posted December 26, 2013 Share Posted December 26, 2013 He's not asking to lock them as lock in the doors, I think he means that it doesn't let you drive it if you ain't of that class. Link to comment
johny46 Posted December 26, 2013 Share Posted December 26, 2013 It would be better to create vehciles in your map file. From there you can easily set their data to certain values. Let's say the data name for vehicles is "owner", you can then set it to one of the values possible for "job" data name. Let's say you have a "Pizzaboy" job, and you've set it to a player. Now you have to create a vehicle with the "owner" data being "Pizzaboy" too, so they can use the vehicle. The script to allow/disallow certain players to use a vehicle is fairly simple. Things you're going to need: The "onVehicleStartEnter" - so you know when a player tries to enter a vehicle, The getElementData() function - so you can compare the player's "job" with the vehicle's "owner" The cancelEvent() function - so you can disallow the player to use a vehicle if the data don't match. Link to comment
Fantanic Posted December 26, 2013 Author Share Posted December 26, 2013 He's not asking to lock them as lock in the doors, I think he means that it doesn't let you drive it if you ain't of that class. Exactly what i wanted It would be better to create vehciles in your map file. From there you can easily set their data to certain values. Let's say the data name for vehicles is "owner", you can then set it to one of the values possible for "job" data name. Let's say you have a "Pizzaboy" job, and you've set it to a player. Now you have to create a vehicle with the "owner" data being "Pizzaboy" too, so they can use the vehicle. The script to allow/disallow certain players to use a vehicle is fairly simple. Things you're going to need:The "onVehicleStartEnter" - so you know when a player tries to enter a vehicle, The getElementData() function - so you can compare the player's "job" with the vehicle's "owner" The cancelEvent() function - so you can disallow the player to use a vehicle if the data don't match. Hhhm was confused a sec , so the functions are onVehicleStartEnter and GetElementData() and cancelEvent() Will try to make it tongiht oh with map editor dont rlly get a thing , dont we need to create the vehicle in the script and not via map editor? Link to comment
johny46 Posted December 26, 2013 Share Posted December 26, 2013 You don't have to use the map editor at all. Just add the cars in your map file using any text editor. That makes the mapmanager resource responsible of creating all the vehicles and stuff, so you can concentrate on the script itself. It makes things just so much easier than using createVehicle() all the time. Link to comment
Spajk Posted December 27, 2013 Share Posted December 27, 2013 line 9: local gangGroup = getElementData( client, "HLS", skin.name ) What's skin.name supposed to be? Also, use thePlayer instead of "client" local gangGroup = getElementData( thePlayer, "HLS" ) Link to comment
Fantanic Posted December 27, 2013 Author Share Posted December 27, 2013 line 9: local gangGroup = getElementData( client, "HLS", skin.name ) What's skin.name supposed to be? Also, use thePlayer instead of "client" local gangGroup = getElementData( thePlayer, "HLS" ) This script didnt worked You don't have to use the map editor at all. Just add the cars in your map file using any text editor. That makes the mapmanager resource responsible of creating all the vehicles and stuff, so you can concentrate on the script itself. It makes things just so much easier than using createVehicle() all the time. I meant that i dont know how to 'combine' it like u just have to place a car and then u have to locate that car or? BTW i want only 1 vehicle locked to 'HLS' and not all the vehicles with other words u just locked 1 car wich is created not the whole ID Link to comment
Fantanic Posted December 27, 2013 Author Share Posted December 27, 2013 Its has soomething to do with GetElementData from the element : bad argument @ 'setElementData" [expected element at argument 1, got nil] (line 9) Link to comment
Spajk Posted December 27, 2013 Share Posted December 27, 2013 What should element data "HLS" contain? Link to comment
Fantanic Posted December 28, 2013 Author Share Posted December 28, 2013 What should element data "HLS" contain? Isnt it supposed to be the group? Link to comment
Spajk Posted December 28, 2013 Share Posted December 28, 2013 Well, does it contain the group name or just true/false ? Link to comment
Fantanic Posted December 28, 2013 Author Share Posted December 28, 2013 Well, does it contain the group name or just true/false ? It contains the group name (its the group name) Link to comment
Spajk Posted December 28, 2013 Share Posted December 28, 2013 local vehicle = createVehicle(506, 2100.2697, 1397.4947, 10.3, 0, 0, 0) setElementData(vehicle, "HLS", "groupname") addEventHandler("onVehicleStartEnter", root, function(thePlayer, seat, jacked, door) local vehicleOwner = getElementData(source, "HLS") local gangGroup = getElementData(thePlayer, "HLS") if (not vehicleOwner) then return end if (gangGroup ~= vehicleOwner) then outputChatBox("This car is locked and belongs to the following class: Admins", thePlayer, 245, 20, 20, false) cancelEvent() end end ) Replace the groupname on line 2 with the name of the group. Link to comment
Fantanic Posted December 29, 2013 Author Share Posted December 29, 2013 Oh thank you , By the way i got 1 more last question ; I would like to lock a class actualy Here is an example : I added a team 'Squads' , after that i added FBI and SWAT I would like to lock only FBI to a ACL and SWAT to a other ACL so FBI members cant spawn SWAT i tought this should work but it isnt working ; local classACL = aclGetGroup( skin.name ); local plrAccount = getPlayerAccount( client ); if ( classACL ) then if ( not isGuestAccount( plrAccount ) ) and ( not isObjectInACLGroup( "user." .. getAccountName( plrAccount ), classACL ) ) then outputChatBox( "You are not member of this team/gang. Choose different team!", client, 200, 50, 50 ); requestMenu( client ); return; elseif isGuestAccount( plrAccount ) then outputChatBox( "If you are member of \"" .. skin.name .. "\" then please log in before you proceed.", client, 200, 50, 50 ); requestMenu( client ); return; end end (this i on line 21 at main_s.lua if u need the whole file tell me then i post it here , skin.name is difined as : if spawned then setElementData( client, "Team", class.name ) setElementData( client, "Job", skin.name ) Link to comment
Fantanic Posted December 29, 2013 Author Share Posted December 29, 2013 job skin.name = the second spawn wich i want to lock actualy ^^ Link to comment
Fantanic Posted December 30, 2013 Author Share Posted December 30, 2013 local vehicle = createVehicle(506, 2100.2697, 1397.4947, 10.3, 0, 0, 0) setElementData(vehicle, "HLS", "groupname") addEventHandler("onVehicleStartEnter", root, function(thePlayer, seat, jacked, door) local vehicleOwner = getElementData(source, "HLS") local gangGroup = getElementData(thePlayer, "HLS") if (not vehicleOwner) then return end if (gangGroup ~= vehicleOwner) then outputChatBox("This car is locked and belongs to the following class: Admins", thePlayer, 245, 20, 20, false) cancelEvent() end end ) Replace the groupname on line 2 with the name of the group. Am i also able to lock it to 2 classes? I tried to use 2 times setElementData(vehicle, "HLS", "SWAT HQ") And then again setElementData(vehicle, "HLS", "SWAT Member") With 1 element it works only Link to comment
Drakath Posted December 30, 2013 Share Posted December 30, 2013 I think the one data will replace another. Try changing HLS to HLS2 like this: setElementData(vehicle, "HLS2", "SWAT Member") Link to comment
Fantanic Posted December 30, 2013 Author Share Posted December 30, 2013 I think the one data will replace another. Try changing HLS to HLS2 like this: setElementData(vehicle, "HLS2", "SWAT Member") Didnt worked 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