Jump to content

Small Buy Problem \:


Recommended Posts

Posted

Hi all i have littel problem with Shop_Weapons

is when player try to buy a medKit and his health is 100 %

the

outputChatBox('Your Health is 100%)

else

outputChatBox('You Have Bought Medkit')

and same as armor

addEventHandler("onClientGUIClick",getRootElement(), 
function (player) 
            if (source == GUIEditor_Button[29]) then 
                guiSetVisible (GUIEditor_Window[1],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[30]) then 
                guiSetVisible (GUIEditor_Window[2],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[1]) then 
                money = getPlayerMoney (source) 
                if (money >= 100) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Pistol $100",225,225,0) 
                takePlayerMoney(100) 
                triggerServerEvent ("give45",getLocalPlayer(),give45) 
                else 
                guiSetVisible(GUIEditor_Window[2],true) 
                guiSetVisible(GUIEditor_Window[1],false) 
                end 
            elseif (source == GUIEditor_Button[2]) then 
                money = getPlayerMoney (source) 
                if (money >= 200) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Silenced $200",225,225,0) 
                takePlayerMoney(200) 
                triggerServerEvent ("givesilenced",getLocalPlayer(),givesilenced) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[3]) then 
                money = getPlayerMoney (source) 
                if (money >= 600) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Desert Eagle $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("givedeagle",getLocalPlayer(),givedeagle) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[4]) then 
                money = getPlayerMoney (source) 
                if (money >= 500) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Shotgun $500",225,225,0) 
                takePlayerMoney(500) 
                triggerServerEvent ("givesh",getLocalPlayer(),givesh) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[5]) then 
                money = getPlayerMoney (source) 
                if (money >= 700) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Sawn Off $700",225,225,0) 
                takePlayerMoney(700) 
                triggerServerEvent ("giveso",getLocalPlayer(),giveso) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[6]) then 
                money = getPlayerMoney (source) 
                if (money >= 1000) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a SPAZ-12 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveSP",getLocalPlayer(),giveSP) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[7]) then 
                money = getPlayerMoney (source) 
                if (money >= 400) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Tec-9 $400",225,225,0) 
                takePlayerMoney(400) 
                triggerServerEvent ("givetec",getLocalPlayer(),givetec) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[8]) then 
                money = getPlayerMoney (source) 
                if (money >= 600) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Uzi $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("giveuzi",getLocalPlayer(),giveuzi) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[9]) then 
                money = getPlayerMoney (source) 
                if (money >= 800) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a MP5 $800",225,225,0) 
                takePlayerMoney(800) 
                triggerServerEvent ("givemp5",getLocalPlayer(),givemp5) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[11]) then 
                money = getPlayerMoney (source) 
                if (money >= 1000) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought an AK-47 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveak",getLocalPlayer(),giveak) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[10]) then 
                money = getPlayerMoney (source) 
                if (money >= 2000) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a M4 $2000",225,225,0) 
                takePlayerMoney(2000) 
                triggerServerEvent ("givem4",getLocalPlayer(),givem4) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[13]) then 
                money = getPlayerMoney (source) 
                if (money >= 3000) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Sniper $3000",225,225,0) 
                takePlayerMoney(3000) 
                triggerServerEvent ("gives",getLocalPlayer(),gives) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[12]) then 
                money = getPlayerMoney (source) 
                if (money >= 1000) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a Country Sniper $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givecs",getLocalPlayer(),givecs) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[25]) then 
             if getPlayerMoney( localPlayer ) >= 1000 
                outputChatBox ("You bought a MedKit $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givehealth",getLocalPlayer(),givehealth) 
                elseif getElementHealth( localPlayer ) ~= 100 then 
                outputChatBox('Your Health is 100% You Cant Buy MedKit',source,255,255,0) 
                end 
            elseif (source == GUIEditor_Button[26]) then 
              if getPlayerMoney( localPlayer ) >= 1000 
                outputChatBox ("You bought a Bullet Proof Vest $1500",225,225,0) 
                takePlayerMoney(1500) 
                triggerServerEvent ("givearmor",getLocalPlayer(),givearmor) 
                elseif getPedArmor ( localPlayer ) ~= 100 then 
                outputChatBox('Your Armor is Alredy 100% You Cant Buy Armor',source,255,255,0) 
                end 
            elseif (source == GUIEditor_Button[29]) then 
                guiSetVisible(GUIEditor_Window[2],false) 
                guiSetVisible(GUIEditor_Window[1],false) 
                 
        end 
end) 

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

I really don't get you from what you've said but if you're talking about checking HP and not giving MedKit to the player who already has 100% health then there's solution:

if getPlayerMoney( localPlayer ) >= 1000 then 
                if getElementHealth( localPlayer ) < 100 then 
                outputChatBox ("You bought a MedKit $1000",225,225,0) 
                takePlayerMoney(1000)--I advise you to do it serverside 
                triggerServerEvent ("givehealth",getLocalPlayer(),givehealth) 
                else 
                outputChatBox('Your Health is 100% You Cant Buy MedKit',source,255,255,0) 
                end 
end 

Posted

Yub AMARANT Thats What i mean

and dont worry about takePlayerMoney in this mta verison its fixed clientSide and server side work :wink:

and it dont work go lot of errors .

Posted (edited)

try this:

addEventHandler("onClientGUIClick",guiRoot, 
function () 
                money = getPlayerMoney (localPlayer) 
            if (source == GUIEditor_Button[29]) then 
                guiSetVisible (GUIEditor_Window[1],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[30]) then 
                guiSetVisible (GUIEditor_Window[2],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[1]) then 
                if (money >= 100) then 
                outputChatBox ("You bought a Pistol $100",225,225,0) 
                takePlayerMoney(100) 
                triggerServerEvent ("give45",getLocalPlayer(),give45) 
                else 
                guiSetVisible(GUIEditor_Window[2],true) 
                guiSetVisible(GUIEditor_Window[1],false) 
                end 
            elseif (source == GUIEditor_Button[2]) then 
                if (money >= 200) then 
                outputChatBox ("You bought a Silenced $200",225,225,0) 
                takePlayerMoney(200) 
                triggerServerEvent ("givesilenced",getLocalPlayer(),givesilenced) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[3]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Desert Eagle $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("givedeagle",getLocalPlayer(),givedeagle) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[4]) then 
                if (money >= 500) then 
                outputChatBox ("You bought a Shotgun $500",225,225,0) 
                takePlayerMoney(500) 
                triggerServerEvent ("givesh",getLocalPlayer(),givesh) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[5]) then 
                if (money >= 700) then 
                outputChatBox ("You bought a Sawn Off $700",225,225,0) 
                takePlayerMoney(700) 
                triggerServerEvent ("giveso",getLocalPlayer(),giveso) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[6]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a SPAZ-12 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveSP",getLocalPlayer(),giveSP) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[7]) then 
                if (money >= 400) then 
                outputChatBox ("You bought a Tec-9 $400",225,225,0) 
                takePlayerMoney(400) 
                triggerServerEvent ("givetec",getLocalPlayer(),givetec) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[8]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Uzi $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("giveuzi",getLocalPlayer(),giveuzi) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[9]) then 
                if (money >= 800) then 
                outputChatBox ("You bought a MP5 $800",225,225,0) 
                takePlayerMoney(800) 
                triggerServerEvent ("givemp5",getLocalPlayer(),givemp5) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[11]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought an AK-47 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveak",getLocalPlayer(),giveak) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[10]) then 
                if (money >= 2000) then 
                outputChatBox ("You bought a M4 $2000",225,225,0) 
                takePlayerMoney(2000) 
                triggerServerEvent ("givem4",getLocalPlayer(),givem4) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[13]) then 
                if (money >= 3000) then 
                outputChatBox ("You bought a Sniper $3000",225,225,0) 
                takePlayerMoney(3000) 
                triggerServerEvent ("gives",getLocalPlayer(),gives) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[12]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a Country Sniper $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givecs",getLocalPlayer(),givecs) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[25]) then 
             if getPlayerMoney( localPlayer ) >= 1000 
                outputChatBox ("You bought a MedKit $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givehealth",getLocalPlayer(),givehealth) 
                elseif getElementHealth( localPlayer ) ~= 100 then 
                outputChatBox('Your Health is 100% You Cant Buy MedKit',source,255,255,0) 
                end 
            elseif (source == GUIEditor_Button[26]) then 
              if getPlayerMoney( localPlayer ) >= 1000 
                outputChatBox ("You bought a Bullet Proof Vest $1500",225,225,0) 
                takePlayerMoney(1500) 
                triggerServerEvent ("givearmor",getLocalPlayer(),givearmor) 
                elseif getPedArmor ( localPlayer ) ~= 100 then 
                outputChatBox('Your Armor is Alredy 100% You Cant Buy Armor',source,255,255,0) 
                end 
            elseif (source == GUIEditor_Button[29]) then 
                guiSetVisible(GUIEditor_Window[2],false) 
                guiSetVisible(GUIEditor_Window[1],false) 
                
        end 
end,true) 

Edited by Guest
Posted

and i event try this but has erros see

addEventHandler("onClientGUIClick",guiRoot, 
function () 
                money = getPlayerMoney (localPlayer) 
            if (source == GUIEditor_Button[29]) then 
                guiSetVisible (GUIEditor_Window[1],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[30]) then 
                guiSetVisible (GUIEditor_Window[2],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[1]) then 
                if (money >= 100) then 
                outputChatBox ("You bought a Pistol $100",225,225,0) 
                takePlayerMoney(100) 
                triggerServerEvent ("give45",getLocalPlayer(),give45) 
                else 
                guiSetVisible(GUIEditor_Window[2],true) 
                guiSetVisible(GUIEditor_Window[1],false) 
                end 
            elseif (source == GUIEditor_Button[2]) then 
                if (money >= 200) then 
                outputChatBox ("You bought a Silenced $200",225,225,0) 
                takePlayerMoney(200) 
                triggerServerEvent ("givesilenced",getLocalPlayer(),givesilenced) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[3]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Desert Eagle $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("givedeagle",getLocalPlayer(),givedeagle) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[4]) then 
                if (money >= 500) then 
                outputChatBox ("You bought a Shotgun $500",225,225,0) 
                takePlayerMoney(500) 
                triggerServerEvent ("givesh",getLocalPlayer(),givesh) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[5]) then 
                if (money >= 700) then 
                outputChatBox ("You bought a Sawn Off $700",225,225,0) 
                takePlayerMoney(700) 
                triggerServerEvent ("giveso",getLocalPlayer(),giveso) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[6]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a SPAZ-12 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveSP",getLocalPlayer(),giveSP) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[7]) then 
                if (money >= 400) then 
                outputChatBox ("You bought a Tec-9 $400",225,225,0) 
                takePlayerMoney(400) 
                triggerServerEvent ("givetec",getLocalPlayer(),givetec) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[8]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Uzi $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("giveuzi",getLocalPlayer(),giveuzi) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[9]) then 
                if (money >= 800) then 
                outputChatBox ("You bought a MP5 $800",225,225,0) 
                takePlayerMoney(800) 
                triggerServerEvent ("givemp5",getLocalPlayer(),givemp5) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[11]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought an AK-47 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveak",getLocalPlayer(),giveak) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[10]) then 
                if (money >= 2000) then 
                outputChatBox ("You bought a M4 $2000",225,225,0) 
                takePlayerMoney(2000) 
                triggerServerEvent ("givem4",getLocalPlayer(),givem4) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[13]) then 
                if (money >= 3000) then 
                outputChatBox ("You bought a Sniper $3000",225,225,0) 
                takePlayerMoney(3000) 
                triggerServerEvent ("gives",getLocalPlayer(),gives) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[12]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a Country Sniper $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givecs",getLocalPlayer(),givecs) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[25]) and getPlayerMoney( source) ==  1000 and getElementHealth(source) < 100 then 
                outputChatBox ("You bought a MedKit $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givehealth",getLocalPlayer(),givehealth) 
                else 
                outputChatBox('You Health is alredy 100% You Cant Buy This',source,255,0,0) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
           elseif (source == GUIEditor_Button[26]) and getPlayerMoney( source) 1000 and getPedArmor(source) < 100 then 
                outputChatBox ("You bought a Bullet Proof Vest $1500",225,225,0) 
                takePlayerMoney(1500) 
                triggerServerEvent ("givearmor",getLocalPlayer(),givearmor) 
                else 
                outputChatBox('Your Armor is Alredy 100% You Cant Buy Armor',source,255,255,0) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == button) then 
                guiSetVisible(GUIEditor_Window[2],false) 
                guiSetVisible(GUIEditor_Window[1],false) 
                
        end 
end,true) 

Posted

I found the problem, try this:

addEventHandler("onClientGUIClick",guiRoot,function() 
            local money = getPlayerMoney(localPlayer) 
            if (source == GUIEditor_Button[29]) then 
                guiSetVisible (GUIEditor_Window[1],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[30]) then 
                guiSetVisible (GUIEditor_Window[2],false) 
                showCursor (false) 
            elseif (source == GUIEditor_Button[1]) then 
                if (money >= 100) then 
                outputChatBox ("You bought a Pistol $100",225,225,0) 
                takePlayerMoney(100) 
                triggerServerEvent ("give45",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[2],true) 
                guiSetVisible(GUIEditor_Window[1],false) 
                end 
            elseif (source == GUIEditor_Button[2]) then 
                if (money >= 200) then 
                outputChatBox ("You bought a Silenced $200",225,225,0) 
                takePlayerMoney(200) 
                triggerServerEvent ("givesilenced",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[3]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Desert Eagle $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("givedeagle",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[4]) then 
                if (money >= 500) then 
                outputChatBox ("You bought a Shotgun $500",225,225,0) 
                takePlayerMoney(500) 
                triggerServerEvent ("givesh",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[5]) then 
                if (money >= 700) then 
                outputChatBox ("You bought a Sawn Off $700",225,225,0) 
                takePlayerMoney(700) 
                triggerServerEvent ("giveso",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[6]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a SPAZ-12 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveSP",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[7]) then 
                if (money >= 400) then 
                outputChatBox ("You bought a Tec-9 $400",225,225,0) 
                takePlayerMoney(400) 
                triggerServerEvent ("givetec",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[8]) then 
                if (money >= 600) then 
                outputChatBox ("You bought a Uzi $600",225,225,0) 
                takePlayerMoney(600) 
                triggerServerEvent ("giveuzi",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[9]) then 
                if (money >= 800) then 
                player = getLocalPlayer() 
                outputChatBox ("You bought a MP5 $800",225,225,0) 
                takePlayerMoney(800) 
                triggerServerEvent ("givemp5",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[11]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought an AK-47 $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("giveak",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[10]) then 
                if (money >= 2000) then 
                outputChatBox ("You bought a M4 $2000",225,225,0) 
                takePlayerMoney(2000) 
                triggerServerEvent ("givem4",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[13]) then 
                if (money >= 3000) then 
                outputChatBox ("You bought a Sniper $3000",225,225,0) 
                takePlayerMoney(3000) 
                triggerServerEvent ("gives",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[12]) then 
                if (money >= 1000) then 
                outputChatBox ("You bought a Country Sniper $1000",225,225,0) 
                takePlayerMoney(1000) 
                triggerServerEvent ("givecs",localPlayer) 
                else 
                guiSetVisible(GUIEditor_Window[1],false) 
                guiSetVisible(GUIEditor_Window[2],true) 
                end 
            elseif (source == GUIEditor_Button[25]) then 
                if getElementHealth(localPlayer) == 100 then --Check their health first 
                    outputChatBox('Your Health is 100% You Cant Buy MedKit',source,255,255,0) 
                else 
                    if money >= 1000 then --forgot then 
                        outputChatBox ("You bought a MedKit $1000",225,225,0) 
                        takePlayerMoney(1000) 
                        triggerServerEvent ("givehealth",localPlayer) 
                    end 
                end 
            elseif (source == GUIEditor_Button[26]) then 
                if getPedArmor(localPlayer) == 100 then --check their armor health first 
                    outputChatBox('Your Armor is Alredy 100% You Cant Buy Armor',source,255,255,0) 
                else 
                    if money >= 1000 then --forgot then 
                        outputChatBox ("You bought a Bullet Proof Vest $1500",225,225,0) 
                        takePlayerMoney(1500) 
                        triggerServerEvent ("givearmor",getLocalPlayer(),givearmor) 
                    end 
                end 
            elseif (source == GUIEditor_Button[29]) then 
                guiSetVisible(GUIEditor_Window[2],false) 
                guiSetVisible(GUIEditor_Window[1],false) 
                
        end 
end,true) 

Posted
Jaysds1 i love to Make gunLinces

can you show me how to do gunlinces ?

:wink:

save all in account data on mysql/sql/ etc

and later

local acc = getPlayerAccount(source) 
if getAccountData(acc,"onHaveGunLicense") ~= true or 1 then 
--code 
else 
     outputChatBox ("* Sorry but you not have a Gun License",source,255,255,255,true) 
end 

Posted

Your double check is wrong, you have to getAccountData again for the second check:

local acc = getPlayerAccount(source) 
if not getAccountData(acc,"onHaveGunLicense") or tonumber(getAccountData(acc,"onHaveGunLicense")) ~= 1 then 
--code 
end 

Posted

so for example well be like this ?

--client-side 
addEvent('onHaveGunLicense', true) 
addEventHandler('onHaveGunLicense', root, function() 
button = guiCreateButton('Buy License',0,0,0) 
end) 
--serverSide 
local acc = getPlayerAccount(source) 
if not getAccountData(acc,"onHaveGunLicense") or tonumber(getAccountData(acc,"onHaveGunLicense")) ~= 1 then 
triggerClientEvent('onHaveGunLicense', source) 
else 
outputChatBox('You Dont Have GunLicense',source,255,255,0) 
end 

Posted
dont worry about takePlayerMoney in this mta verison its fixed clientSide and server side work

source?

what version?

by theway, what was fixed?

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