SkiZo Posted December 1, 2016 Share Posted December 1, 2016 Hello , I Need Some Help Please There Is Cylinder In CLAN And I Wonna If Some One Hit It It In ACL Clan1 Get A Car BUT Here The Problem !! I Can't Make The Last Car Destroy When He Hit The Marker Again :\ ~> Script local Marker1 = createMarker (-1529.0632324219, 455.220062255886, 6, "cylinder", 3, 0, 0, 255, 100) function Vehicle1 ( hitPlayer, getPlayerVehicle ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Clan1")) then local Veh1 = createVehicle(541, -1529.0632324219, 455.220062255886, 7.2) warpPedIntoVehicle ( hitPlayer, Veh1 ) else outputChatBox ("Clan1: Access denied", hitPlayer, 100, 0, 0) end end addEventHandler( "onMarkerHit", Marker1, Vehicle1) Link to comment
LoPollo Posted December 1, 2016 Share Posted December 1, 2016 #1 your argument hitPlayer (first argument passed from onMarkerHit) is not always a player. It's an element. If you want to do stuff when the player enters then check if that elements is a player (getElementType) #2 I'm not sure about what you want to achieve: you spawn a veh when the "player" enters... and want to destroy the vehicle when THAT vehicle enters again the marker right? If that's correct, then use a table to stores all the possibles vehicles (more players in Clan1 are able to hit the markers i guess). Then check when the marker is hit if the hitElement is one of these vehicles, then destory it. Not tested and i'm tired, but even it something may be missing the general "plan" is this if i understood the problem Link to comment
SkiZo Posted December 2, 2016 Author Share Posted December 2, 2016 Take An Exemple ! I Hit The Marker I Get A Car ! I Hit It Again And I Get Car But The Last Car That I take Still there :\ Link to comment
LoPollo Posted December 2, 2016 Share Posted December 2, 2016 Tell me if i understand right: 1. Every time the marker is hit a vehicle will be spawned. 2. Every time the marker is hit, the previous vehicle spawned by the marker should be destroyed. 3. The hit-event code will get executed only if a player* hit the marker: for example if the spawned vehicle gets pushed inside but NO player hit the marker, nothing from this script should happen *The player must be in a given ACL group If this is right then when you assign to Veh1 the vehicle (createVehicle), the previous vehicle, if it exists, must be destroyed: local Marker1 = createMarker (-1529.0632324219, 455.220062255886, 6, "cylinder", 3, 0, 0, 255, 100) function Vehicle1 ( hitPlayer, getPlayerVehicle ) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Clan1")) then if isElement(Veh1) then destroyElement( Veh1 ) end local Veh1 = createVehicle(541, -1529.0632324219, 455.220062255886, 7.2) warpPedIntoVehicle ( hitPlayer, Veh1 ) else outputChatBox ("Clan1: Access denied", hitPlayer, 100, 0, 0) end end addEventHandler( "onMarkerHit", Marker1, Vehicle1) Actually if i'm right (not sure though) if the vehicle is destroyed by something that is NOT the script, it's possible the "id" of Veh1 will be referenced to another object. So additionals checks should be made: adding an handler on vehicle explode event bound to Veh1 where you nil the value of Veh1 should solve the issue Correct me if someone with these knowledge read this, i'm tired and really not sure about this 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