mint3d Posted June 15, 2014 Posted June 15, 2014 Ok so I am making a VIP system but I need help how can I make it check to see if the player already has a vip vehicle spawned before spawning another one? function vehiclecar ( ) if exports.vip_system:isPlayerDonator(source) then x,y,z = getElementPosition ( source ) createVehicle ( 411, x + 3, y, z + 1 ) outputChatBox("[VIP]Vehicle Created",source,255,255,0,false) end end addEvent( "vehiclecar", true ) addEventHandler( "vehiclecar", getRootElement(),vehiclecar ) Skype: Jordan_Nymph
xXMADEXx Posted June 15, 2014 Posted June 15, 2014 This: local vehs = { } function vehiclecar ( ) if exports.vip_system:isPlayerDonator(source) then if ( isElement ( vehs [ source ] ) ) then -- Here the vehicle already exists end local x,y,z = getElementPosition ( source ) vehs [ source ] = createVehicle ( 411, x + 3, y, z + 1 ) outputChatBox("[VIP]Vehicle Created",source,255,255,0,false) end end addEvent( "vehiclecar", true ) addEventHandler( "vehiclecar", getRootElement(),vehiclecar ) The Ultimate Lua Tutorial! | MTA PHP SDK
mint3d Posted June 15, 2014 Author Posted June 15, 2014 It didn't work... I could click VIP Vehicle then click it again and 2 spawned.. I want it to destroy it if they click VIP Vehicle so only one can spawn at a time for each player.. Skype: Jordan_Nymph
Cadell Posted June 15, 2014 Posted June 15, 2014 Use setelement on spawn setelwmwnt vehicle vip or blaaa and on spawn check if get element data return false esle spawn return tru Script Trading Status Successful Trading : 26 Scam : 0 On Sale : Banking System SQL Based On Sale : Housing System MySQL Based Download and Support my new script on Community : http://community.mtasa.com/index.php?p=resources&s=details&id=11686 SQL Based Housing
mint3d Posted June 15, 2014 Author Posted June 15, 2014 the makes no sense to me? Skype: Jordan_Nymph
Et-win Posted June 15, 2014 Posted June 15, 2014 (edited) function vehiclecar() if exports.vip_system:isPlayerDonator(source) then local vehicleExists = false for placeNumber, vehicleData in ipairs(getElementsByType("vehicle")) do if (getElementData(vehicleData, "vehicleVIPFrom") == getPlayerAccount(source)) then vehicleExists = true end end if (vehicleExists == false) then x,y,z = getElementPosition ( source ) local vehicleVIP = createVehicle ( 411, x + 3, y, z + 1 ) setElementData(vehicleVIP, "vehicleVIPFrom", getPlayerAccount(source)) outputChatBox("[VIP]Vehicle Created",source,255,255,0,false) else outputChatBox("[VIP]Your vehicle was already created", source, 255, 255, 0, false) end end end addEvent( "vehiclecar", true ) addEventHandler( "vehiclecar", getRootElement(),vehiclecar ) First check all vehicles on data "vehicleVIPFrom". If one has the account data of the client on it (Since I think the player is logged in, right?), then he will get the message he already have his vehicle created. Otherwise create the vehicle and set the account data on it from the client. Edited June 15, 2014 by Guest ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
Et-win Posted June 15, 2014 Posted June 15, 2014 Edited my code. ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
mint3d Posted June 15, 2014 Author Posted June 15, 2014 I don't know if you can help me I am making a VIP System and ye I am gonna use that code ^ I haven't tested it but I was thinking like because your code doesn't destroy it how can I make it destroy it? This is my client side.. function VIPCVehicle () triggerServerEvent ("VIPCVehicle", localplayer) end addEventHandler("onClientGUIClick", GUIEditor.button[3], VIPCVehicle, false) function VIPDVehicle () triggerServerEvent ("VIPDVehicle", localplayer) end addEventHandler("onClientGUIClick", GUIEditor.button[4], VIPDVehicle, false) Skype: Jordan_Nymph
Et-win Posted June 15, 2014 Posted June 15, 2014 Do you want to have it destroyed, and immediately spawn the new one? ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
mint3d Posted June 15, 2014 Author Posted June 15, 2014 Nah I have 2 buttons Vehicle Create and Vehicle Destroy.. One Creates it other Destroys it.. Skype: Jordan_Nymph
Et-win Posted June 15, 2014 Posted June 15, 2014 function vehicledcar() if exports.vip_system:isPlayerDonator(source) then local vehicleExists = false for placeNumber, vehicleData in ipairs(getElementsByType("vehicle")) do if (getElementData(vehicleData, "vehicleVIPFrom") == getPlayerAccount(source)) then vehicleExists = true destroyElement(vehicleData) --You can change this to blowVehicle too, if you like that more end end if (vehicleExists == true) then outputChatBox("[VIP]Your vehicle was destroyed successfully", source, 255, 255, 0, false) elseif (vehicleExists == false) then outputChatBox("[VIP]No vehicles found", source, 255, 255, 0, false) end end end addEvent( "VIPDVehicle", true ) addEventHandler( "VIPDVehicle", getRootElement(),vehicledcar ) ~Scripts~ Clan War System V1.2.0 ~Maps~ [DM]Et-win - The Run [FUN]Et-win - Drift Rocket [FUN]Et-win - Drift Rocket // [DD]Et-win - Cross 3xC
TAPL Posted June 15, 2014 Posted June 15, 2014 I don't know if you can help me I am making a VIP System and ye I am gonna use that code ^ I haven't tested it but I was thinking like because your code doesn't destroy it how can I make it destroy it? This is my client side.. function VIPCVehicle () triggerServerEvent ("VIPCVehicle", localplayer) end addEventHandler("onClientGUIClick", GUIEditor.button[3], VIPCVehicle, false) function VIPDVehicle () triggerServerEvent ("VIPDVehicle", localplayer) end addEventHandler("onClientGUIClick", GUIEditor.button[4], VIPDVehicle, false) local vehs = {} addEvent("VIPCVehicle", true) addEventHandler("VIPCVehicle", root, function() if exports.vip_system:isPlayerDonator(source) then if (isElement(vehs[source])) then destroyElement(vehs[source]) vehs[source] = nil end local x, y, z = getElementPosition(source) vehs[source] = createVehicle(411, x+3, y, z+1) outputChatBox("[VIP]Vehicle Created", source, 255, 255, 0) end end) addEvent("VIPDVehicle", true) addEventHandler("VIPDVehicle", root, function() if exports.vip_system:isPlayerDonator(source) then if (isElement(vehs[source])) then destroyElement(vehs[source]) vehs[source] = nil outputChatBox("[VIP]Vehicle Destroyed", source, 255, 0, 0) end end end) function VIPCVehicle () triggerServerEvent ("VIPCVehicle", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[3], VIPCVehicle, false) function VIPDVehicle () triggerServerEvent ("VIPDVehicle", localPlayer) end addEventHandler("onClientGUIClick", GUIEditor.button[4], VIPDVehicle, false)
mint3d Posted June 15, 2014 Author Posted June 15, 2014 Thanks TAPL your stuff always works for me.. Skype: Jordan_Nymph
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