Jump to content

SOS


Zar_Man

Recommended Posts

Waht is Problem 

Server :

 

function khh (theplayer)
 
        pool = getPlayerMoney(theplayer)
        if pool >= 50 then
       
        takePlayerMoney(theplayer,400)
        vehshoti = createVehicle (411,72.373046875,-66.451171875,0.609375)
        setVehicleColor(vehshoti,1,1,1)
       
        outputChatBox("Info : Shoma Mashin Peugeot Pars Ra Daryaft Kardid.",theplayer,0,255,0)
       
        warpPedIntoVehicle(theplayer,vehshoti)
        else
            outputChatBox("Info : Shoma Pol Nadarid",theplayer,255,0,0)
    end
end
 
addEvent("barmavad",true)
addEventHandler("barmavad",root,khh)



 
function Kh(theplayer)
 
        pool = getPlayerMoney(theplayer)
        if pool >= 50 then
       
        takePlayerMoney(theplayer,400)
        vehshoti = createVehicle (411,72.373046875,-66.451171875,0.609375)
        setVehicleColor(vehshoti,1,1,1)
       
        outputChatBox("Info : Shoma Mashin Peugeot Pars Ra Daryaft Kardid.",theplayer,0,255,0)
       
        warpPedIntoVehicle(theplayer,vehshoti)
        else
            outputChatBox("Info : Shoma Pol Nadarid",theplayer,255,0,0)
 
    end
end
 
Client
 
local screenW, screenH = guiGetScreenSize()
CardBackGround = guiCreateStaticImage((screenW - 1800) / 2, (screenH - 1000) / 2, 1700, 1000, "image.png", false)
CardPurchase1 = guiCreateStaticImage(1000, 251, 388, 113, "Group 1.png", false, CardBackGround)
CardPurchase2 = guiCreateStaticImage(1000, 400, 388, 113, "Group 2.png", false, CardBackGround)
CardPurchase3 = guiCreateStaticImage(1000, 560, 388, 113, "Group 3.png", false, CardBackGround)
CardClose = guiCreateStaticImage(1450, 100, 43, 45, "Group 4.png", false, CardBackGround)
guiSetVisible(CardBackGround, false)
 
addEventHandler("onClientGUIClick",root,
function ()
    if source == CardPurchase1 then
      triggerServerEvent("barmavad",LocalPlayer)
 
    elseif source == CardPurchase2 then
       triggerServerEvent("barmavadshoti",LocalPlayer)
 
    --elseif source == CardPurchase then
      -- triggerServerEvent("")
 
    elseif source == CardClose then
        guiSetVisible(CardBackGround, false)
        showCursor(false)
    end
end
)
 
m4 = createMarker(71.189453125,-85.0009765625,-0.5,"cylinder",1.5)
 
addEventHandler("onClientMarkerHit",m4,
function ()
    guiSetVisible(CardBackGround, true)
    showCursor(true)
end)
 
addEventHandler("onClientMarkerLeave",m4,
function ()
    guiSetVisible(CardBackGround, false)
    showCursor(false)
end)
Link to comment

*What is the problem* 
I guess that what we should ask you too .. because you didn't explain

Regarding your code .. the problem is when you press 'CardPurchase1' :
 1. there is a problem when triggering the event .. 'LocalPlayer' and 'localPlayer' are not the same , you should use 'localPlayer' .. [ THAT INCLUDES ANY TRIGGER SERVER EVENT ATTEMPT ]
2. In the server side event .. there is no global variable 'theplayer' .. just replace it with 'source' the source is the client/player who pressed the button

that should fix your problem
Additional : next time use 'debugscript 3' command to debug your script and when you have a problem you should see lines below the screen ( ERROR / WARNING ) explaining what caused the problem then you can try to fix it yourself or post about the problem in the forum attaching explanation and any errors/warnings.. if you have a problem and nothing shows up in the debug .. post about the problem with an EXPLANATION !

Good Luck.

Link to comment
3 hours ago, Zar_Man said:
I get this error
\s.lua:16: attempt to compare number with Boolean
 But my line 16 is this, can you tell me what to do?

if pol >= 50 then

Regarding your code in the previous message
 

 pool = getPlayerMoney(source)
        if pool >= 50 then

the variable name is 'pool' not 'pol'
so replace 'pol' with  'pool' :)

EDIT: the error said 'boolean' soo that's not the problem .. the problem is propably because u didn't replace 'theplayer' with 'source'
Edited by MouNiR.Dz
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...