Jump to content

[HELP] Panel to buy cars


Andrixx

Recommended Posts

Hello, what happens is that yesterday was testing the guieditor which I liked a lot I did a panel to buy cars, works well the only problem is that when leaving the car, the character can not enter, as if you were the doors BLOCKED.

    function Panel() 
        Ventana = guiCreateWindow(439, 57, 401, 419, "Ventana prueba", false) 
        guiWindowSetSizable(Ventana, false) 
        guiSetAlpha(Ventana, 0.78) 
  
        Inf = guiCreateButton(34, 121, 157, 79, "Infernus ($11000)", false, Ventana) 
        Bull = guiCreateButton(217, 121, 157, 79, "Bullet ($10000)", false, Ventana) 
        Che = guiCreateButton(34, 210, 157, 79, "Cheetah ($9000)", false, Ventana) 
        Com = guiCreateButton(217, 210, 157, 79, "Comet ($8000)", false, Ventana) 
        bik = guiCreateButton(221, 299, 157, 79, "Bike ($6000)", false, Ventana) 
        Sul = guiCreateButton(34, 299, 157, 79, "Sultan ($7000)", false, Ventana) 
        Cerrar = guiCreateButton(124, 397, 155, 65, "Cerrar", false, Ventana) 
         
        showCursor ( true ) 
         
        addEventHandler ( "onClientGUIClick", Cerrar, Exit, false ) 
        addEventHandler ( "onClientGUIClick", Inf, infernus, false ) 
        addEventHandler ( "onClientGUIClick", Bull, bullet, false ) 
        addEventHandler ( "onClientGUIClick", Che, cheetah, false ) 
        addEventHandler ( "onClientGUIClick", Com, comet, false ) 
        addEventHandler ( "onClientGUIClick", bik, bike, false ) 
        addEventHandler ( "onClientGUIClick", Sul, sultan, false ) 
    end 
addCommandHandler ( "buy", Panel ) 
  
function Exit () 
showCursor ( false ) 
guiSetVisible (Ventana, not guiGetVisible ( Ventana ) ) 
  
end 
  
  
function infernus() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 411, x +2, y, z +2 ) 
takePlayerMoney ( 11000 ) 
end 
  
function bullet() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 541, x +2, y, z +2 ) 
takePlayerMoney ( 10000 ) 
end 
  
function cheetah() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 415, x +2, y, z +2 ) 
takePlayerMoney ( 9000 ) 
end 
  
function bike() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 509, x +2, y, z +2 ) 
takePlayerMoney ( 8000 ) 
end 
  
function sultan() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 560, x +2, y, z +2 ) 
takePlayerMoney ( 7000 ) 
end 
  
function comet() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 480, x +2, y, z +2 ) 
takePlayerMoney ( 6000 ) 
end 

Link to comment

where am I wrong?

Client:

    function Panel() 
        Ventana = guiCreateWindow(439, 57, 401, 419, "Ventana prueba", false) 
        guiWindowSetSizable(Ventana, false) 
        guiSetAlpha(Ventana, 0.78) 
  
        Inf = guiCreateButton(34, 121, 157, 79, "Infernus ($11000)", false, Ventana) 
        Bull = guiCreateButton(217, 121, 157, 79, "Bullet ($10000)", false, Ventana) 
        Che = guiCreateButton(34, 210, 157, 79, "Cheetah ($9000)", false, Ventana) 
        Com = guiCreateButton(217, 210, 157, 79, "Comet ($8000)", false, Ventana) 
        bik = guiCreateButton(221, 299, 157, 79, "Bike ($6000)", false, Ventana) 
        Sul = guiCreateButton(34, 299, 157, 79, "Sultan ($7000)", false, Ventana) 
        Cerrar = guiCreateButton(124, 397, 155, 65, "Cerrar", false, Ventana) 
         
        showCursor ( true ) 
         
        addEventHandler ( "onClientGUIClick", Cerrar, Exit, false ) 
        triggerServerEvent ( "onClientGUIClick", Inf, infernus, false ) 
        addEventHandler ( "onClientGUIClick", Bull, bullet, false ) 
        addEventHandler ( "onClientGUIClick", Che, cheetah, false ) 
        addEventHandler ( "onClientGUIClick", Com, comet, false ) 
        addEventHandler ( "onClientGUIClick", bik, bike, false ) 
        addEventHandler ( "onClientGUIClick", Sul, sultan, false ) 
    end 
addCommandHandler ( "buy", Panel ) 
  
function Exit () 
showCursor ( false ) 
guiSetVisible (Ventana, not guiGetVisible ( Ventana ) ) 
  
end 
  

Server side:

function infernus() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 411, x +2, y, z +2 ) 
takePlayerMoney ( 11000 ) 
end 

Link to comment
where am I wrong?

Client:

    function Panel() 
        Ventana = guiCreateWindow(439, 57, 401, 419, "Ventana prueba", false) 
        guiWindowSetSizable(Ventana, false) 
        guiSetAlpha(Ventana, 0.78) 
  
        Inf = guiCreateButton(34, 121, 157, 79, "Infernus ($11000)", false, Ventana) 
        Bull = guiCreateButton(217, 121, 157, 79, "Bullet ($10000)", false, Ventana) 
        Che = guiCreateButton(34, 210, 157, 79, "Cheetah ($9000)", false, Ventana) 
        Com = guiCreateButton(217, 210, 157, 79, "Comet ($8000)", false, Ventana) 
        bik = guiCreateButton(221, 299, 157, 79, "Bike ($6000)", false, Ventana) 
        Sul = guiCreateButton(34, 299, 157, 79, "Sultan ($7000)", false, Ventana) 
        Cerrar = guiCreateButton(124, 397, 155, 65, "Cerrar", false, Ventana) 
         
        showCursor ( true ) 
         
        addEventHandler ( "onClientGUIClick", Cerrar, Exit, false ) 
        triggerServerEvent ( "onClientGUIClick", Inf, infernus, false ) 
        addEventHandler ( "onClientGUIClick", Bull, bullet, false ) 
        addEventHandler ( "onClientGUIClick", Che, cheetah, false ) 
        addEventHandler ( "onClientGUIClick", Com, comet, false ) 
        addEventHandler ( "onClientGUIClick", bik, bike, false ) 
        addEventHandler ( "onClientGUIClick", Sul, sultan, false ) 
    end 
addCommandHandler ( "buy", Panel ) 
  
function Exit () 
showCursor ( false ) 
guiSetVisible (Ventana, not guiGetVisible ( Ventana ) ) 
  
end 
  

Server side:

function infernus() 
Jugador = getLocalPlayer() 
x, y, z = getElementPosition (Jugador) 
createVehicle ( 411, x +2, y, z +2 ) 
takePlayerMoney ( 11000 ) 
end 

Wrong !

addEventHandler 
addEvent 
triggerServerEvent 

read the example in the wiki !

for example :

Client Side --

function Click() 
    if ( source == Button ) then 
        triggerServerEvent("Car1",localPlayer) 
        showCursor(true) 
  
    end 
end  
addEventHandler( "onClientGUIClick", root, Click ) 

Server Side --

addEvent("Car1",true)  
addEventHandler("Car1",root,  
 function() 
local PlayerMoney = getPlayerMoney(source) 
 if ( PlayerMoney >= 11000) then 
  takePlayerMoney(source,11000)  
 x,y,z = getElementPosition ( source ) 
Vehicle = createVehicle ( id, x, y, z +2 ) 
  
     end  
 end 
)  

# Edited

Edited by Guest
Link to comment

Server Side --

addEvent("Car1",true)  
addEventHandler("Car1",root,  
 function() 
local PlayerMoney = getPlayerMoney(source) 
 if ( PlayerMoney >= 11000) then 
  takePlayerMoney(source,11000)  
 x,y,z = getElementPosition ( source ) 
Vehicle = createVehicle ( id, x, y, z +2 ) 
  
     end  
  
)  

Forgot 'end'.

Link to comment

Server Side --

addEvent("Car1",true)  
addEventHandler("Car1",root,  
 function() 
local PlayerMoney = getPlayerMoney(source) 
 if ( PlayerMoney >= 11000) then 
  takePlayerMoney(source,11000)  
 x,y,z = getElementPosition ( source ) 
Vehicle = createVehicle ( id, x, y, z +2 ) 
  
     end  
  
)  

Forgot 'end'.

Oh Thanks i forgot to add end -_-" , Edited

Link to comment

fix it thanks to you :mrgreen::mrgreen:

thanks

Client

    function Panel() 
        Ventana = guiCreateWindow(439, 57, 401, 419, "Ventana prueba", false) 
        guiWindowSetSizable(Ventana, false) 
        guiSetAlpha(Ventana, 0.78) 
  
        Inf = guiCreateButton(34, 121, 157, 79, "Infernus ($11000)", false, Ventana) 
        Bull = guiCreateButton(217, 121, 157, 79, "Bullet ($10000)", false, Ventana) 
        Che = guiCreateButton(34, 210, 157, 79, "Cheetah ($9000)", false, Ventana) 
        Com = guiCreateButton(217, 210, 157, 79, "Comet ($8000)", false, Ventana) 
        bik = guiCreateButton(221, 299, 157, 79, "Bike ($6000)", false, Ventana) 
        Sul = guiCreateButton(34, 299, 157, 79, "Sultan ($7000)", false, Ventana) 
        Cerrar = guiCreateButton(124, 397, 155, 65, "Cerrar", false, Ventana) 
         
        showCursor ( true ) 
         
        addEventHandler ( "onClientGUIClick", Cerrar, Exit, false ) 
        addEventHandler ( "onClientGUIClick", Inf, infernus, false ) 
        addEventHandler ( "onClientGUIClick", Bull, bullet, false ) 
        addEventHandler ( "onClientGUIClick", Che, cheetah, false ) 
        addEventHandler ( "onClientGUIClick", Com, comet, false ) 
        addEventHandler ( "onClientGUIClick", bik, bike, false ) 
        addEventHandler ( "onClientGUIClick", Sul, sultan, false ) 
    end 
addCommandHandler ( "buy", Panel ) 
  
function Exit () 
showCursor ( false ) 
guiSetVisible (Ventana, not guiGetVisible ( Ventana ) ) 
  
end 
  
  
function infernus() 
triggerServerEvent ( "Car1", getLocalPlayer() )  
end 

Server Side

function Infeee() 
local PlayerMoney = getPlayerMoney(source) 
 if ( PlayerMoney >= 11000) then 
  takePlayerMoney(source,11000) 
 x,y,z = getElementPosition ( source ) 
Vehicle = createVehicle ( 411, x+2, y, z +2 ) 
  
     end 
 end 
addEvent("Car1",true) 
addEventHandler( "Car1", getRootElement(), Infeee ) 

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