Leonard.DC Posted June 2, 2014 Share Posted June 2, 2014 Hello, im fixing and upgrading a vehicle system that i have founded last 3 mounth ago in a public mediafire link or i think in the community, i dont remember where but im doing this for a friend that ask me a favor, im mired in the hide system, i need when a player quit the server, the vehicles that the player have in the road moves to the 35 dimension, It help because if the server have many players and many buyed vehicles, the server lag and all the vehicles are in the road destroyable for dmer people, i have used all posibilities but nothing work, tested with command and i really dont know why, but it doesn't work Importante server side part of the script: allVehicles = {} addEvent( "requestSendVehicles", true ) addEvent( "onVehicleBuyRequest", true ) addEvent( "requestVehicleMove", true ) addEvent( "onVehicleGift", true ) addEvent( "respawnRequest", true ) function moveVehToDimNow (vehicle) if not isPedInVehicle (source) then setElementDimension (vehicle, 80) outputChatBox ("*******", source, 0, 255, 0) else outputChatBox ("*******", source, 255, 0, 0) end end addEvent( "moveTheVehicleToDim", true ) addEventHandler( "moveTheVehicleToDim", root, moveVehToDimNow) addEventHandler( "onVehicleBuyRequest", root, function ( model, price, x, y, z, rx, ry, rz, dim, int ) if not isGuestAccount( getPlayerAccount( source ) ) then if model and price and x and y and z and dim and int then local veh = createVehicle( model, x, y, z, rx, ry, rz ) setElementDimension( veh, dim ) setElementInterior( veh, int ) takePlayerMoney( source, price ) outputChatBox( "You Buy a "..getVehicleNameFromModel( model ).." !", source, 0, 255, 0 ) triggerClientEvent (source, "buyVehicleHd", source) allVehicles[veh] = getAccountName( getPlayerAccount( source ) ) end else outputChatBox( "Fatal Error.", source, 255, 0, 0 ) end end ) addCommandHandler ("novehi", function () setElementDimension (allVehicles[source], 33) outputChatBox ("All Vehicles Moved To Dimension 33", source, 255, 255, 0) end end) addEventHandler( "onVehicleEnter", root, function ( player, seat ) if seat == 0 then if allVehicles[source] and allVehicles[source] ~= getAccountName( getPlayerAccount( player )) then removePedFromVehicle ( player ) outputChatBox ("This Is Not Your Vehicle", player, 255, 0, 0) triggerClientEvent (player, "failVehicleEnter", player) end end end ) As i say i have tested all the posibilities, but it still doesn't work, this command is supposed to work: addCommandHandler ("novehi", function () setElementDimension (allVehicles[source], 33) outputChatBox ("All Vehicles Moved To Dimension 33", source, 255, 255, 0) end end) But it say bad argument setelementdimension expected element at argument 1 got nil I have tested thsi one too: addCommandHandler ("novehi", function (vehicle) if getElementType( vehicle ) == "vehicle" then setElementDimension (allVehicles[vehicle], 33) outputChatBox ("All Vehicles Moved To Dimension 33", source, 255, 255, 0) end end) No errors and dont work And this one too: addCommandHandler ("novehi", function () setElementDimension (allVehicles[root], 33) outputChatBox ("All Vehicles Moved To Dimension 33", source, 255, 255, 0) end end) Dont work, any solution please? It is a xml database script Original: http://www.mediafire.com/download/1k3xs ... 284%29.zip Link to comment
xXMADEXx Posted June 2, 2014 Share Posted June 2, 2014 In a command, source isn't the player that executed the command. allVehicles = {} addEvent( "requestSendVehicles", true ) addEvent( "onVehicleBuyRequest", true ) addEvent( "requestVehicleMove", true ) addEvent( "onVehicleGift", true ) addEvent( "respawnRequest", true ) function moveVehToDimNow (vehicle) if not isPedInVehicle (source) then setElementDimension (vehicle, 80) outputChatBox ("*******", source, 0, 255, 0) else outputChatBox ("*******", source, 255, 0, 0) end end addEvent( "moveTheVehicleToDim", true ) addEventHandler( "moveTheVehicleToDim", root, moveVehToDimNow) addEventHandler( "onVehicleBuyRequest", root, function ( model, price, x, y, z, rx, ry, rz, dim, int ) if not isGuestAccount( getPlayerAccount( source ) ) then if model and price and x and y and z and dim and int then local veh = createVehicle( model, x, y, z, rx, ry, rz ) setElementDimension( veh, dim ) setElementInterior( veh, int ) takePlayerMoney( source, price ) outputChatBox( "You Buy a "..getVehicleNameFromModel( model ).." !", source, 0, 255, 0 ) triggerClientEvent (source, "buyVehicleHd", source) allVehicles[veh] = getAccountName( getPlayerAccount( source ) ) end else outputChatBox( "Fatal Error.", source, 255, 0, 0 ) end end ) addCommandHandler ("novehi", function ( p ) for i, v in pairs ( allVehicles ) do setElementDimension ( v, 33 ) end outputChatBox ("All Vehicles Moved To Dimension 33", p, 255, 255, 0) end) addEventHandler( "onVehicleEnter", root, function ( player, seat ) if seat == 0 then if allVehicles[source] and allVehicles[source] ~= getAccountName( getPlayerAccount( player )) then removePedFromVehicle ( player ) outputChatBox ("This Is Not Your Vehicle", player, 255, 0, 0) triggerClientEvent (player, "failVehicleEnter", player) end end end ) (I don't recommend change the vehicle dimension, I would recommend using destroyElement and store all the data in a database) Link to comment
Leonard.DC Posted June 2, 2014 Author Share Posted June 2, 2014 Bad argument @setelementdimension expected element at argument 1 got string Ale333, and all the player accounts that are found in the server I think there are a mistake but im little newb in pairs and ipairs functions Can you explain why it say me a error or fix it please Link to comment
Castillo Posted June 6, 2014 Share Posted June 6, 2014 Bad argument @setelementdimension expected element at argument 1 got string Ale333, and all the player accounts that are found in the serverI think there are a mistake but im little newb in pairs and ipairs functions Can you explain why it say me a error or fix it please Post the code and where it says that. Link to comment
Leonard.DC Posted June 6, 2014 Author Share Posted June 6, 2014 addCommandHandler ("novehi", function ( p ) for i, v in pairs ( allVehicles ) do setElementDimension ( v, 33 ) -- Here is it, the error, and it doesn't move the player all vehicles to selected dimension when the player type the command "Bad argument @setelementdimension expected element at argument 1 got string (all the player accounts that are found in the server)" end outputChatBox ("All Vehicles Moved To Dimension 33", p, 255, 255, 0) end) Link to comment
Castillo Posted June 6, 2014 Share Posted June 6, 2014 That's because 'v' in that loop is the account name, change 'v' to 'i' at setElementDimension. 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