Newbie Posted August 3, 2014 Share Posted August 3, 2014 As you see when i buy a car i should be a owner so nobody can drive car. But when i test it with other acc's it fails. Looks like that script does't work as it should No errors At DS3 function BuyTractor () local money = getPlayerMoney(source) if (money > 5000) then takePlayerMoney(source,5000) local vehicleModel = 411 local x,y,z = getElementPosition(source) y = y + 5 local veh = createVehicle(tonumber(vehicleModel),x,y,z) setElementData(veh, "owner", source) else outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) end end addEvent("Car1",true) addEventHandler( "Car1", getRootElement(), BuyTractor ) function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle if ( getElementData(source, "owner") and player ~= getElementData(source, "owner") ) then cancelEvent() outputChatBox ( "You don't have the keys for this vehicle", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
Newbie Posted August 3, 2014 Author Share Posted August 3, 2014 if someone dont get what im trying to do: I made a GUI when player clicks buy car it spawns vehicle near him and i want to set owner (buyer) for it, so nobody other wont be able to drive it Link to comment
Anubhav Posted August 3, 2014 Share Posted August 3, 2014 function BuyTractor () local money = getPlayerMoney(source) if (money > 5000) then takePlayerMoney(source,5000) local vehicleModel = 411 local x,y,z = getElementPosition(source) y = y + 5 local veh = createVehicle(tonumber(vehicleModel),x,y,z) setElementData(veh, "owner", getPlayerName(source)) else outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) end end addEvent("Car1",true) addEventHandler( "Car1", getRootElement(), BuyTractor ) function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle if ( getElementData(source, "owner") and getPlayerName(player) ~= getElementData(source, "owner") ) then cancelEvent() outputChatBox ( "You don't have the keys for this vehicle", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) Link to comment
Anubhav Posted August 3, 2014 Share Posted August 3, 2014 function BuyTractor () local money = getPlayerMoney(source) if (money > 5000) then takePlayerMoney(source,5000) local vehicleModel = 411 local x,y,z = getElementPosition(source) y = y + 5 local veh = createVehicle(tonumber(vehicleModel),x,y,z) setElementData(veh, "owner", getPlayerName(source)) else outputChatBox ( "* Earn more OP (Oil Points) to buy this vehicle", source, 255, 255, 255, true ) end end addEvent("Car1",true) addEventHandler( "Car1", getRootElement(), BuyTractor ) function enterVehicle ( player, seat, jacked ) --when a player enters a vehicle if ( getElementData(source, "owner") and getPlayerName(player) ~= getElementData(source, "owner") ) then cancelEvent() outputChatBox ( "You don't have the keys for this vehicle", player ) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 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