Tete omar Posted August 19, 2012 Share Posted August 19, 2012 Hello , i made this script taking money from the passengers who entered and exited the specific vehicle models. addEventHandler("onPlayerVehicleExit", getRootElement(), function(veh,sea) randomMoney = math.random( 50,200 ) if ( getElementModel( veh ) == 420 or 428 ) then if ( sea == 1 or 2 or 3 ) then if ( getPlayerMoney( source ) >= tonumber( randomMoney ) ) then takePlayerMoney( source, tonumber( randomMoney ) ) end end end end) but unfortunately it takes the money from every vehicle model and every seat i enter and exit .. what's wrong ?. Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 if ( getElementModel( veh ) == 420 or 428 ) then if ( sea == 1 or 2 or 3 ) then should be: if (getElementModel(veh) == 420 or getElementModel(veh) == 428) then if (sea == 1 or sea == 2 or sea == 3) then Link to comment
Tete omar Posted August 19, 2012 Author Share Posted August 19, 2012 yeah thx , i think tonumber is not needed becuase randomMoney is already a number right ? Link to comment
Guest Guest4401 Posted August 19, 2012 Share Posted August 19, 2012 yeah thx , i think tonumber is not needed becuase randomMoney is already a number right ? Yes, it's number. Link to comment
Tete omar Posted August 19, 2012 Author Share Posted August 19, 2012 Thanks karthik thanks tapl Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 You should put randomMoney below this, so it won't make a random number every time you exit from vehicle, you only need it for 420 and 428. if (sea == 1 or sea == 2 or sea == 3) then Link to comment
Tete omar Posted August 19, 2012 Author Share Posted August 19, 2012 You should put randomMoney below this, so it won't make a random number every time you exit from vehicle, you only need it for 420 and 428. if (sea == 1 or sea == 2 or sea == 3) then you mean like that ? addEventHandler("onPlayerVehicleExit", getRootElement(), function(veh,sea) if (getElementModel(veh) == 420 or getElementModel(veh) == 428) then if (sea == 1 or sea == 2 or sea == 3) then randomMoney = math.random( 50,200 ) if ( getPlayerMoney( source ) >= randomMoney ) then takePlayerMoney( source, randomMoney ) end end end end) No i also think it's the same meaning than the other one, and thanks for the attention. Link to comment
TAPL Posted August 19, 2012 Share Posted August 19, 2012 it's will work in both way but it's about performance (less CPU usage), also you should make it local anyway. 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