Jump to content

[HELP] GUI Button problem


BolonZX

Recommended Posts

I made a GUI wheel panel but whenever I click the button ( I've made the function for one button to test it) it gives me Bad argument @ 'IsPedInVehicle'

here is the code:

server

function advan_racingv2 ( player ) 
        if ( isPedInVehicle ( player ) ) then 
            local theVehicle = getPedOccupiedVehicle ( player ) 
            local success = addVehicleUpgrade ( theVehicle, 1080 ) 
            if ( success ) then 
                outputConsole ( " Se ha instalado nuevas llantas.", player ) 
            else 
                outputConsole ( "No se pudo instalar nuevas llantas.", player ) 
            end 
        else 
            outputConsole ( "Nesecitas estar en un vehiculo!", player ) 
        end 
end 
addEvent( "onWheelInstall", true ) 
addEventHandler( "onWheelInstall", getRootElement(), advan_racingv2 ) 

Link to comment

here you go

client

function wheelspanel() 
        panelruedas = guiCreateWindow(415, 224, 426, 514, "TougeZone Panel de Llantas", false) 
        guiSetProperty(panelruedas, "CaptionColour", "FFD90000") 
        guiWindowSetSizable(panelruedas, false) 
        guiSetVisible(panelruedas, false) 
         
        tabpanel1 = guiCreateTabPanel(18, 35, 391, 461, false, panelruedas) 
        tab1 = guiCreateTab("llantas", tabpanel1) 
        scrollpanel1 = guiCreateScrollPane(4, 5, 382, 426, false, tab1) 
  
        advanracingv2 = guiCreateStaticImage(6, 8, 86, 102, "images/advanracingv2.png", false, scrollpanel1) 
        bbs_lm = guiCreateStaticImage(144, 8, 86, 102, "images/bbs_lm.png", false, scrollpanel1) 
        bbs_re = guiCreateStaticImage(271, 8, 86, 102, "images/bbs_re.png", false, scrollpanel1) 
        BBSRK = guiCreateStaticImage(7, 195, 86, 102, "images/BBSRK.png", false, scrollpanel1) 
        enkei_nt03 = guiCreateStaticImage(8, 383, 86, 102, "images/enkei_nt03.png", false, scrollpanel1) 
        fikse_fm10 = guiCreateStaticImage(145, 195, 86, 102, "images/fikse_fm10.png", false, scrollpanel1) 
        hamannraceedition = guiCreateStaticImage(145, 383, 86, 102, "images/hamannraceedition.png", false, scrollpanel1) 
        profil5 = guiCreateStaticImage(271, 190, 86, 102, "images/profil5.png", false, scrollpanel1) 
        ro_jar25 = guiCreateStaticImage(270, 383, 86, 102, "images/ro_jar2-5.png", false, scrollpanel1) 
        ssrgtv01 = guiCreateStaticImage(10, 570, 86, 102, "images/ssrgtv01.png", false, scrollpanel1) 
        ssrprofessorsp1 = guiCreateStaticImage(144, 574, 86, 102, "images/ssrprofessorsp1.png", false, scrollpanel1) 
        te37whiteblue = guiCreateStaticImage(281, 574, 86, 102, "images/te37whiteblue.png", false, scrollpanel1) 
        tenzordc6 = guiCreateStaticImage(8, 762, 86, 102, "images/tenzordc6.png", false, scrollpanel1) 
        tswtrackstar4 = guiCreateStaticImage(144, 762, 86, 102, "images/tswtrackstar4.png", false, scrollpanel1) 
        volkte37blackandred = guiCreateStaticImage(270, 762, 86, 102, "images/volkte37blackandred.png", false, scrollpanel1) 
        volkte37paintable = guiCreateStaticImage(8, 956, 86, 102, "images/volkte37paintable.png", false, scrollpanel1) 
        wedssportstc105n = guiCreateStaticImage(145, 956, 86, 102, "images/wedssportstc105n.png", false, scrollpanel1) 
        wheelbutton1 = guiCreateButton(17, 120, 65, 60, "Advan Racing v2", false, scrollpanel1) 
        wheelbutton2 = guiCreateButton(18, 307, 65, 60, "BBS RK", false, scrollpanel1) 
        wheelbutton3 = guiCreateButton(19, 500, 65, 60, "Enkei NT03", false, scrollpanel1) 
        wheelbutton4 = guiCreateButton(371, 373, 15, 15, "", false, scrollpanel1) 
        wheelbutton5 = guiCreateButton(155, 120, 65, 60, "BBS LM", false, scrollpanel1) 
        wheelbutton6 = guiCreateButton(282, 120, 65, 60, "BBS RE", false, scrollpanel1) 
        wheelbutton7 = guiCreateButton(155, 307, 65, 60, "Fikse FM10", false, scrollpanel1) 
        wheelbutton8 = guiCreateButton(155, 500, 65, 60, "Hamann Race Edition", false, scrollpanel1) 
        wheelbutton9 = guiCreateButton(281, 307, 65, 60, "Fikse Profil5", false, scrollpanel1) 
        wheelbutton10 = guiCreateButton(281, 500, 65, 60, "RO_JA r2-5", false, scrollpanel1) 
        wheelbutton11 = guiCreateButton(19, 682, 65, 60, "SSR GTV01", false, scrollpanel1) 
        wheelbutton12 = guiCreateButton(156, 682, 65, 60, "SSR Proffesor SP1", false, scrollpanel1) 
        wheelbutton13 = guiCreateButton(281, 682, 65, 60, "Volk te37 Blanco y azul", false, scrollpanel1) 
        wheelbutton14 = guiCreateButton(18, 878, 65, 60, "Tenzo R DC6", false, scrollpanel1) 
        wheelbutton15 = guiCreateButton(156, 878, 65, 60, "TSW Trackstar 4", false, scrollpanel1) 
        wheelbutton16 = guiCreateButton(281, 878, 65, 60, "Volk te37 Negro y Rojo", false, scrollpanel1) 
        wheelbutton17 = guiCreateButton(18, 1068, 65, 60, "Volk te37 (se pueden pintar)", false, scrollpanel1) 
        wheelbutton18 = guiCreateButton(155, 1068, 65, 60, "Weds Sports TC105n", false, scrollpanel1) 
  
        addEventHandler ( "onClientGUIClick", wheelbutton1, advan_racingv2, false ) 
        addCommandHandler("wheelpanel", toggleWindow)    
end 
addEventHandler("onClientResourceStart", resourceRoot, wheelspanel) 
  
function toggleWindow() 
    guiSetVisible(panelruedas, not guiGetVisible(panelruedas)) 
    showCursor(guiGetVisible(panelruedas)) 
end 
  
function advan_racingv2 () 
    triggerServerEvent ( "onWheelInstall", getLocalPlayer() ) 
    toggleWindow() 
end 

Link to comment

You didn't defined it\

function advan_racingv2 ( playerV )

local playerV = getPlayerFromName ( checkedPlayerName )

if ( playerV ) then

if ( isPedInVehicle ( playerV ) ) then

local theVehicle = getPedOccupiedVehicle ( playerV )

local success = addVehicleUpgrade ( theVehicle, 1080 )

if ( success ) then

outputConsole ( " Se ha instalado nuevas llantas.", player )

else

outputConsole ( "No se pudo instalar nuevas llantas.", player )

end

else

outputConsole ( "Nesecitas estar en un vehiculo!", player )

end

end

addEvent( "onWheelInstall", true )

addEventHandler( "onWheelInstall", getRootElement(), advan_racingv2 )

Link to comment
  • Moderators
Np.

Sorry to say that but you didn't helped him, you just renamed the variable player into playerV which is totally pointless. Plus, you didn't renamed player into playerV for the outputConsole so you are just breaking his function.

The real solution was to send localPlayer (which is the same as getLocalPlayer()) with the trigger:

triggerServerEvent ( "onWheelInstall", getLocalPlayer(), getLocalPlayer()) 

or

triggerServerEvent ( "onWheelInstall", localPlayer, localPlayer ) 

Another solution (the best one) is to use the implicit variable source into the function:

function advan_racingv2 () 
        if isPedInVehicle ( source) then 
            local theVehicle = getPedOccupiedVehicle ( source ) 
            local success = addVehicleUpgrade ( theVehicle, 1080 ) 
            if success then 
                outputConsole ( " Se ha instalado nuevas llantas.", source) 
            else 
                outputConsole ( "No se pudo instalar nuevas llantas.", source) 
            end 
        else 
            outputConsole ( "Nesecitas estar en un vehiculo!", source) 
        end 
end 
addEvent( "onWheelInstall", true ) 
addEventHandler( "onWheelInstall", getRootElement(), advan_racingv2 ) 

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...