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) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

no i was talking about takePlayerMoney to Amarant

and the resource

its got errors and wont work

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

haha Jaysds1 X-Shadow Comes and fucked up every body alredy fixed befour 20 sec Thank's i realy love you :wink:

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

Jaysds1 i think i fucked up my slef only :(

its still Buy even if my health and armor == 100

i even try what you post dont work.

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

same thing i just well look to the posts in the fourm to fined a problem like me

i dont want make you tired Jaysds1 :wink:

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

haha i made 100% of shop without errors like you all bgus .

Alpha +1

i well try make it :D

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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 

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

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 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

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

source?

what version?

by theway, what was fixed?

CiTLh.png

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