TrickyTommy Posted August 27, 2017 Posted August 27, 2017 Hi! If i hit a marker an if node should run. It runs, but it is very strange, and i don't know what the problem is. I would like to make a script, that if i hit the marker(s) with a vehicle that is given in the table, it would just put something into debugscript 3, i can continue from there. What i have done so far: driveInAndGo = {596, 597, 598, 416, 533} function borderMarkerHit(client) --if driveInAndGo[getElementModel(client)]? if getElementType (client) == "vehicle" then outputDebugString ("the hit element was a vehicle") else outputDebugString ("the hit element was not a vehicle") end --getVehicleSirensOn end addEventHandler ("onMarkerHit", borderMarkerLeaveLS, borderMarkerHit) addEventHandler ("onMarkerHit", borderMarkerLeaveSF, borderMarkerHit) The strange thing is, that either the message that says hit element was a vehicle and hit element was not a vehicle gets displayed... I would continue it like this: if hit element was vehicle and it's ID is in the driveInAndGo table, something would happen.
bebo1king Posted August 27, 2017 Posted August 27, 2017 driveInAndGo = {596, 597, 598, 416, 533} function borderMarkerHit(client) --if driveInAndGo[getElementModel(client)]? if getElementType (client) == "player" then local Vehicle = getPedOccupiedVehicle(client) if Vehicle then outputDebugString ("the hit element was a vehicle") else outputDebugString ("the hit element was not a vehicle") end end --getVehicleSirensOn end addEventHandler ("onMarkerHit", borderMarkerLeaveLS, borderMarkerHit) addEventHandler ("onMarkerHit", borderMarkerLeaveSF, borderMarkerHit) 1
TrickyTommy Posted August 27, 2017 Author Posted August 27, 2017 thanks, and how sould i do the table-call?
Moderators IIYAMA Posted August 27, 2017 Moderators Posted August 27, 2017 ? driveInAndGo = {[596] = true, [597] = true, [598] = true, [416] = true, [533] = true} ? if driveInAndGo[getElementModel(Vehicle)] then
TrickyTommy Posted August 27, 2017 Author Posted August 27, 2017 thanks... but why do i need the brackets and the other stuff? on vehicle id list page there are no brackets and equalation marks and booleans just vehicle ids...
Moderators IIYAMA Posted August 27, 2017 Moderators Posted August 27, 2017 Because this: driveInAndGo = {596, 597, 598, 416, 533} Is the same as: driveInAndGo = {[1] = 596, [2] = 597, [3] = 598, [4] = 416, [5] = 533} You only don't see the index fields. [<index>] = <data> local data = driveInAndGo[index] print(data) true = yes, false = no if true then --do stuff else -- false or nil --do other stuff end
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