Jump to content

weird problem


Castillo

Recommended Posts

hey, while scripting my panel i got stuck in a function that seems to dont work, i will post code here maybe someone can help me.

server:

function fixVehicle(client)
local theVehicle = getPedOccupiedVehicle ( client )
if ( theVehicle ) then
fixVehicle ( theVehicle )
local rx, ry, rz = getVehicleRotation ( theVehicle )
if ( rx > 110 ) and ( rx < 250 ) then
local x, y, z = getElementPosition ( theVehicle )
setVehicleRotation ( theVehicle, rx + 180, ry, rz )
setElementPosition ( theVehicle, x, y, z + 2 )
end
end
end

client:

function repairVehicle()
if source == repair then
	selectedPlayer = guiGridListGetItemText ( playersList, guiGridListGetSelectedItem (playersList), 1 )   
if ( guiGridListGetSelectedItem ( playersList ) ~= -1 ) then
triggerServerEvent ("repairVeh", getRootElement(), selectedPlayer, client)
else
outputChatBox("No user selected.", nil , 255, 0, 0, false)
end
end
end

Link to comment
When you create a function with the name of one native MTA function, you overwrite it.. That will make MTA fixVehicle function unavailable... Be careful when naming your functions.

ok, i changed to repairVehicle as function name but still same problem with getPedOccupiedVehicle, this is the error.

Bad argument @ "getPedOccupiedVehicle"

Link to comment
When you create a function with the name of one native MTA function, you overwrite it.. That will make MTA fixVehicle function unavailable... Be careful when naming your functions.

ok, i changed to repairVehicle as function name but still same problem with getPedOccupiedVehicle, this is the error.

Bad argument @ "getPedOccupiedVehicle"

Your client parameter will be string (player's name from grid list, I suppose), this will also overwrite MTA's client variable which is passed to server event with triggerServerEvent. Just rename the parameter name to something more like what the argument will be (like playerName) and inside the function getPlayerFromName. Also, change all the client to player and try this code:

function repairVehicle( playerName )
local player = getPlayerFromName( playerName );
 
-- rest of your code ...
end

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...