abu5lf Posted March 25, 2012 Share Posted March 25, 2012 (edited) addEvent("gived",true) addEventHandler("gived",root, function(Player) local PlayerMoney = getPlayerMoney(source) local x,y,z = getElementPosition( player ) if ( PlayerMoney >= 150) then takePlayerMoney(source,150) createVehicle( source , 456,x+1,y,z ) local name = getPlayerName(source) outputChatBox ( "#ffffff" .. name .. " #ffffff buy Vehicle ...", getRootElement(), 255, 0, 0, true ) else outputChatBox("dont have money", source, 255, 0, 0, true) end end ) Edited December 25, 2012 by Guest Link to comment
-ffs-Sniper Posted March 25, 2012 Share Posted March 25, 2012 addEvent("gived",true) addEventHandler("gived",root, function(player) local PlayerMoney = getPlayerMoney(source) local x,y,z = getElementPosition( player ) if ( PlayerMoney >= 150) then takePlayerMoney(source,150) createVehicle(456,x+1,y,z ) local name = getPlayerName(source) outputChatBox ( "#ffffff" .. name .. " #ffffff buy Vehicle ...", getRootElement(), 255, 0, 0, true ) else outputChatBox("dont have money", source, 255, 0, 0, true) end end ) Link to comment
GanJaRuleZ Posted March 25, 2012 Share Posted March 25, 2012 (edited) addEvent("gived",true) addEventHandler("gived",root, function() local playerm = getPlayerMoney(source) local x,y,z = getElementPosition(source) if( playerm >= 150) then takePlayerMoney(source,150) createVehicle(456,x+1,y,z) local name = getPlayerName(source) outputChatBox("#FFFFFF"..name.."#FFFFFF buy vehicle ...",root,255,0,0,true) else outputChatBox("You don't have enough money",source,255,0,0,true) end end) And when you trigger it , it must be something like : triggerServerEvent("gived",getLocalPlayer()) If you trigger it from server side , please reply , cuz it will need to remake the entire code.. @@-ffs-Sniper source is nil , player maybe it's definied , and you're using them both. Wrong. Edited March 25, 2012 by Guest Link to comment
abu5lf Posted March 25, 2012 Author Share Posted March 25, 2012 addEvent("gived",true) addEventHandler("gived",root, function(player) local PlayerMoney = getPlayerMoney(source) local x,y,z = getElementPosition( player ) if ( PlayerMoney >= 150) then takePlayerMoney(source,150) createVehicle(456,x+1,y,z ) local name = getPlayerName(source) outputChatBox ( "#ffffff" .. name .. " #ffffff buy Vehicle ...", getRootElement(), 255, 0, 0, true ) else outputChatBox("dont have money", source, 255, 0, 0, true) end end ) WARNING: Vh\server.lua:5: Bad argument @ 'getElementPosition' ERROR: vh\server.lua:8: attempt to perform arithmetic on local 'x' (a boolean value) Link to comment
unknooooown Posted March 25, 2012 Share Posted March 25, 2012 (edited) addEvent("gived",true) addEventHandler("gived",root, function() local PlayerMoney = getPlayerMoney(source) local x,y,z = getElementPosition(source) if ( PlayerMoney >= 150) then takePlayerMoney(source,150) createVehicle(456,x+1,y,z ) local name = getPlayerName(source) outputChatBox ( "#ffffff" .. name .. " #ffffff buy Vehicle ...", getRootElement(), 255, 0, 0, true ) else outputChatBox("dont have money", source, 255, 0, 0, true) end end ) There is no need to define 'player' in the function, as 'source' is already the player element whenever you trigger that event. I just removed 'player' from the function and replaced it with 'source' - Should work. Edited March 25, 2012 by Guest Link to comment
unknooooown Posted March 25, 2012 Share Posted March 25, 2012 It's aleardy posted Oh.. I didnt see that - I just spotted the mistake when I saw his script, so I didnt even read your posts Sorry.. Hehe. Link to comment
abu5lf Posted March 25, 2012 Author Share Posted March 25, 2012 addEvent("gived",true) addEventHandler("gived",root, function() local PlayerMoney = getPlayerMoney(source) local x,y,z = getElementPosition(source) if ( PlayerMoney >= 150) then takePlayerMoney(source,150) createVehicle(456,x+1,y,z ) local name = getPlayerName(source) outputChatBox ( "#ffffff" .. name .. " #ffffff buy Vehicle ...", getRootElement(), 255, 0, 0, true ) else outputChatBox("dont have money", source, 255, 0, 0, true) end end ) There is no need to define 'player' in the function, as 'source' is already the player element whenever you trigger that event. I just removed 'player' from the function and replaced it with 'source' - Should work. Thanks, but how do make it, if another vehicle procurement disappear first? Link to comment
unknooooown Posted March 25, 2012 Share Posted March 25, 2012 Please rephrase your question Link to comment
abu5lf Posted March 25, 2012 Author Share Posted March 25, 2012 OK, how do you remove the vehicle after time? Link to comment
abu5lf Posted March 25, 2012 Author Share Posted March 25, 2012 setTimer blowVehicle Thanks, Link to comment
unknooooown Posted March 25, 2012 Share Posted March 25, 2012 setTimer blowVehicle Thanks, If you want a "clean remove" - Just use destroyElement( vehicle ) destroyElement 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