Jump to content

Problem with LUA code


Khalil

Recommended Posts

Firstly, when I click 'buttonAccept', I don't get moved to the Criminal Team. Debug says Bad Argument @ setPlayerTeam

Also, debug says :109: ')' expected to close '(' at line 84 near 'elseif'

Here is the code

SERVER SIDE

local CrimTeam = createTeam ( "Criminal" ) 
function takejob (source) 
  getPlayerName(source)  
  if ( CrimTeam ) then 
    outputChatBox ( "Go to the marker to buy drugs", source, 0, 255, 0 ) 
    setPlayerTeam(source, CrimTeam ) 
end 
end 
addEvent ( "setTeam", true ) 
addEventHandler ( "setTeam", root, takejob ) 
  
  

CLIENT SIDE

local lp = getLocalPlayer ( ) 
local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) 
local ped = createPed ( 59, 2043, 1557, 10 ) 
createBlipAttachedTo ( marker, 25 ) 
sx, sy = guiGetScreenSize () 
win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) 
guiWindowSetSizable(win, false) 
buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) 
buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) 
memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) 
guiMemoSetReadOnly(memoOne, true) 
guiSetVisible ( win, false ) 
  
drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) 
guiWindowSetSizable(drugsWindow, false) 
gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) 
guiGridListAddColumn(gridList, "Drug", 0.3) 
guiGridListAddColumn(gridList, "Buy for", 0.3) 
guiGridListAddColumn(gridList, "Sell for", 0.3) 
for i = 1, 5 do 
    guiGridListAddRow(gridList) 
end 
meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) 
guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) 
guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) 
cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) 
guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) 
guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) 
heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) 
guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) 
guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) 
ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) 
guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) 
guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) 
marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) 
guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) 
guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) 
guiGridListSetSelectionMode ( gridlist, 0 ) 
buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) 
buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) 
guiSetVisible ( drugsWindow, false ) 
  
  
  
function openGUI ( p ) 
       if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end 
        if ( getElementModel (lp) ) == 59 then 
        outputChatBox ( "You already have this job", 255, 0, 0 ) 
        return 
        end 
        guiSetVisible ( win, true ) 
        showCursor ( true ) 
end 
addEventHandler("onClientMarkerHit", marker, openGUI ) 
  
addEventHandler ("onClientGUIClick",root, function ()  
    if (source == buttonCancel ) then 
         guiSetVisible ( win, false ) 
         showCursor ( false ) 
    elseif (source == buttonAccept ) then 
        guiSetVisible ( win, false ) 
        showCursor ( false ) 
        triggerServerEvent ("setTeam", lp) 
        setElementModel ( lp, 59 ) 
        drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) 
        createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) 
        addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) 
    end 
end 
) 
  
function invPed() 
cancelEvent() 
end 
addEventHandler("onClientPedDamage", ped, invPed) 
  
function openDrugsGUI ( p ) 
 if ( getElementType ( p ) == "player" and p == lp ) then 
  guiSetVisible ( drugsWindow, true ) 
  showCursor ( true ) 
 end 
end 
  
addEventHandler ("onClientGUIClick",root, function ()   
    if (source == buttonCancelTwo ) then 
         guiSetVisible ( win, false ) 
         showCursor ( false ) 
    elseif (source == buttonBuy ) then 
        guiSetVisible ( win, false ) 
        showCursor ( false ) 
        outputChatBox ( "Go to the marker to sell your drugs" ) 
        destroyElement ( drugsMarker ) 
        drugBought = guiGridListGetSelectedItem ( gridList ) 
        if (drugBought == meth) then 
        if (getPlayerMoney ( )) >= 500000 then 
            takePlayerMoney ( 500000 ) 
            end 
    elseif ((getPlayerMoney ( )) < 500000) then 
            outputChatBox ("You don't have enough money for that", 255, 0, 0 ) 
            end 
    elseif (drugBought == Cocaine) then 
        if (getPlayerMoney ( )) >= 50000 then 
            takePlayerMoney ( 50000 ) 
            end 
        elseif ((getPlayerMoney ( )) < 50000) then 
        outputChatBox ("You don't have enough money for that", 255, 0, 0 ) 
        end 
        end 
    elseif (drugBought == heroin) then 
        if (getPlayerMoney ( )) >= 25000 then 
            takePlayerMoney ( 25000 ) 
            end 
    elseif (getPlayerMoney < 25000) then 
            outputChatBox ("You don't have enough money for that", 255, 0, 0 ) 
            end 
    elseif (drugBought == ecstasy) then 
        if (getPlayerMoney ( )) >= 15000 then 
            takePlayerMoney (15000) 
            end 
    elseif (getPlayerMoney < 15000) then 
            outputChatBox ("You don't have enough money for that", 255, 0, 0 ) 
            end 
    elseif (drugBought == marijuana) then 
        if (getPlayerMoney >= 5000) then 
            takePlayerMoney (5000) 
            end 
    elseif (getPlayerMoney < 5000) 
        outputChatBox ("You don't have enough money for that", 255, 0, 0 ) 
    end 
end 
) 

Link to comment
local lp = getLocalPlayer ( ) 
local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) 
local ped = createPed ( 59, 2043, 1557, 10 ) 
createBlipAttachedTo ( marker, 25 ) 
sx, sy = guiGetScreenSize () 
win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) 
guiWindowSetSizable(win, false) 
buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) 
buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) 
memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) 
guiMemoSetReadOnly(memoOne, true) 
guiSetVisible ( win, false ) 
  
drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) 
guiWindowSetSizable(drugsWindow, false) 
gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) 
guiGridListAddColumn(gridList, "Drug", 0.3) 
guiGridListAddColumn(gridList, "Buy for", 0.3) 
guiGridListAddColumn(gridList, "Sell for", 0.3) 
for i = 1, 5 do 
    guiGridListAddRow(gridList) 
end 
meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) 
guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) 
guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) 
cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) 
guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) 
guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) 
heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) 
guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) 
guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) 
ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) 
guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) 
guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) 
marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) 
guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) 
guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) 
guiGridListSetSelectionMode ( gridlist, 0 ) 
buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) 
buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) 
guiSetVisible ( drugsWindow, false ) 
  
  
  
function openGUI ( p ) 
       if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end 
        if ( getElementModel (lp) ) == 59 then 
        outputChatBox ( "You already have this job", 255, 0, 0 ) 
        return 
        end 
        guiSetVisible ( win, true ) 
        showCursor ( true ) 
end 
addEventHandler("onClientMarkerHit", marker, openGUI ) 
  
addEventHandler ("onClientGUIClick",root, function () 
    if (source == buttonCancel ) then 
         guiSetVisible ( win, false ) 
         showCursor ( false ) 
    elseif (source == buttonAccept ) then 
        guiSetVisible ( win, false ) 
        showCursor ( false ) 
        triggerServerEvent ("setTeam", lp) 
        setElementModel ( lp, 59 ) 
        drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) 
        createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) 
        addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) 
    end 
end 
) 
  
function invPed() 
cancelEvent() 
end 
addEventHandler("onClientPedDamage", ped, invPed) 
  
function openDrugsGUI ( p ) 
 if ( getElementType ( p ) == "player" and p == lp ) then 
  guiSetVisible ( drugsWindow, true ) 
  showCursor ( true ) 
 end 
end 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == buttonCancelTwo ) then 
            guiSetVisible ( win, false ) 
            showCursor ( false ) 
        elseif ( source == buttonBuy ) then 
            guiSetVisible ( win, false ) 
            showCursor ( false ) 
            outputChatBox ( "Go to the marker to sell your drugs" ) 
            destroyElement ( drugsMarker ) 
            drugBought = guiGridListGetSelectedItem ( gridList ) 
            if ( drugBought == meth ) then 
                if ( getPlayerMoney ( ) >= 500000 ) then 
                    takePlayerMoney ( 500000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            end 
        elseif ( drugBought == Cocaine ) then 
            if ( getPlayerMoney ( ) >= 50000 ) then 
                takePlayerMoney ( 50000 ) 
            else 
                outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
            end 
        elseif ( drugBought == heroin ) then 
            if ( getPlayerMoney ( ) >= 25000 ) then 
                takePlayerMoney ( 25000 ) 
            else 
                outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
            end 
        elseif ( drugBought == ecstasy ) then 
            if ( getPlayerMoney ( ) >= 15000 ) then 
                takePlayerMoney ( 15000 ) 
            else 
                outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
            end 
        elseif ( drugBought == marijuana ) then 
            if ( getPlayerMoney ( ) >= 5000 ) then 
                takePlayerMoney ( 5000 ) 
            else 
                outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
            end 
        end 
    end 
) 

Link to comment
local lp = getLocalPlayer ( ) 
local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) 
local ped = createPed ( 59, 2043, 1557, 10 ) 
createBlipAttachedTo ( marker, 25 ) 
sx, sy = guiGetScreenSize () 
win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) 
guiWindowSetSizable(win, false) 
buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) 
buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) 
memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) 
guiMemoSetReadOnly(memoOne, true) 
guiSetVisible ( win, false ) 
  
drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) 
guiWindowSetSizable(drugsWindow, false) 
gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) 
guiGridListAddColumn(gridList, "Drug", 0.3) 
guiGridListAddColumn(gridList, "Buy for", 0.3) 
guiGridListAddColumn(gridList, "Sell for", 0.3) 
for i = 1, 5 do 
    guiGridListAddRow(gridList) 
end 
meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) 
guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) 
guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) 
cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) 
guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) 
guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) 
heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) 
guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) 
guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) 
ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) 
guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) 
guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) 
marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) 
guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) 
guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) 
guiGridListSetSelectionMode ( gridlist, 0 ) 
buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) 
buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) 
guiSetVisible ( drugsWindow, false ) 
  
  
  
function openGUI ( p ) 
       if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end 
        if ( getElementModel (lp) ) == 59 then 
        outputChatBox ( "You already have this job", 255, 0, 0 ) 
        return 
        end 
        guiSetVisible ( win, true ) 
        showCursor ( true ) 
end 
addEventHandler("onClientMarkerHit", marker, openGUI ) 
  
addEventHandler ("onClientGUIClick",root, function () 
    if (source == buttonCancel ) then 
         guiSetVisible ( win, false ) 
         showCursor ( false ) 
    elseif (source == buttonAccept ) then 
        guiSetVisible ( win, false ) 
        showCursor ( false ) 
        triggerServerEvent ("setTeam", lp) 
        setElementModel ( lp, 59 ) 
        drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) 
        createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) 
        addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) 
    end 
end 
) 
  
function invPed() 
cancelEvent() 
end 
addEventHandler("onClientPedDamage", ped, invPed) 
  
function openDrugsGUI ( p ) 
 if ( getElementType ( p ) == "player" and p == lp ) then 
  guiSetVisible ( drugsWindow, true ) 
  showCursor ( true ) 
 end 
end 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == buttonCancelTwo ) then 
            guiSetVisible ( win, false ) 
            showCursor ( false ) 
        elseif ( source == buttonBuy ) then 
            guiSetVisible ( win, false ) 
            showCursor ( false ) 
            outputChatBox ( "Go to the marker to sell your drugs" ) 
            destroyElement ( drugsMarker ) 
            drugBought = guiGridListGetSelectedItem ( gridList ) 
            if ( drugBought == meth ) then 
                if ( getPlayerMoney ( ) >= 500000 ) then 
                    takePlayerMoney ( 500000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == Cocaine ) then 
                if ( getPlayerMoney ( ) >= 50000 ) then 
                    takePlayerMoney ( 50000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == heroin ) then 
                if ( getPlayerMoney ( ) >= 25000 ) then 
                    takePlayerMoney ( 25000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == ecstasy ) then 
                if ( getPlayerMoney ( ) >= 15000 ) then 
                    takePlayerMoney ( 15000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == marijuana ) then 
                if ( getPlayerMoney ( ) >= 5000 ) then 
                    takePlayerMoney ( 5000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            end 
        end 
    end 
) 

Link to comment

I did this

if ( getPlayerMoney ( ) >= 50000 ) then 
                    triggerServerEvent ( "cocaineMoney", lp ) 

and methMoney etc.

and this is serverside

function cocaineMoney () 
takePlayerMoney ( 50000, source ) 
end 
addEvent ("cocaineMoney", true) 
addEventHandler ( "cocaineMoney", root, cocaineMoney ) 

Still doesnt work, no money is taken..

Link to comment
local lp = getLocalPlayer ( ) 
local marker = createMarker ( 2043, 1557, 10, "cylinder", 2.0, 0, 0, 255, 0 ) 
local ped = createPed ( 59, 2043, 1557, 10 ) 
createBlipAttachedTo ( marker, 25 ) 
sx, sy = guiGetScreenSize () 
win = guiCreateWindow(282, 212, 462, 285, "Drug Dealer Job Description", false) 
guiWindowSetSizable(win, false) 
buttonCancel = guiCreateButton(49, 236, 119, 39, "Cancel", false, win) 
buttonAccept = guiCreateButton(270, 236, 119, 39, "Accept", false, win) 
memoOne = guiCreateMemo(9, 24, 443, 206, "Spawn a boat and go to the marker on your map. Buy some drugs and go to the next marker to sell your drugs.", false, win) 
guiMemoSetReadOnly(memoOne, true) 
guiSetVisible ( win, false ) 
  
drugsWindow = guiCreateWindow(328, 235, 455, 304, "Drugs Market", false) 
guiWindowSetSizable(drugsWindow, false) 
gridList = guiCreateGridList(9, 25, 429, 216, false, drugsWindow) 
guiGridListAddColumn(gridList, "Drug", 0.3) 
guiGridListAddColumn(gridList, "Buy for", 0.3) 
guiGridListAddColumn(gridList, "Sell for", 0.3) 
for i = 1, 5 do 
    guiGridListAddRow(gridList) 
end 
meth = guiGridListSetItemText(gridList, 0, 1, "Meth", false, false) 
guiGridListSetItemText(gridList, 0, 2, "$500,000", false, false) 
guiGridListSetItemText(gridList, 0, 3, "$750,000", false, false) 
cocaine = guiGridListSetItemText(gridList, 1, 1, "Cocaine", false, false) 
guiGridListSetItemText(gridList, 1, 2, "$50,000", false, false) 
guiGridListSetItemText(gridList, 1, 3, "$100,000", false, false) 
heroin = guiGridListSetItemText(gridList, 2, 1, "Heroin", false, false) 
guiGridListSetItemText(gridList, 2, 2, "$25,000", false, false) 
guiGridListSetItemText(gridList, 2, 3, "$40,000", false, false) 
ecstasy = guiGridListSetItemText(gridList, 3, 1, "Ecstasy", false, false) 
guiGridListSetItemText(gridList, 3, 2, "$15,000", false, false) 
guiGridListSetItemText(gridList, 3, 3, "$25,000", false, false) 
marijuana = guiGridListSetItemText(gridList, 4, 1, "Marijuana", false, false) 
guiGridListSetItemText(gridList, 4, 2, "$5,000", false, false) 
guiGridListSetItemText(gridList, 4, 3, "$7,500", false, false) 
guiGridListSetSelectionMode ( gridList, 0 ) 
buttonCancelTwo = guiCreateButton(38, 247, 118, 47, "Cancel", false, drugsWindow) 
buttonBuy = guiCreateButton(263, 247, 118, 47, "Buy", false, drugsWindow) 
guiSetVisible ( drugsWindow, false ) 
  
  
  
function openGUI ( p ) 
       if ( getElementType ( p ) ~= 'player' or p ~= localPlayer ) then return end 
        if ( getElementModel (lp) ) == 59 then 
        outputChatBox ( "You already have this job", 255, 0, 0 ) 
        return 
        end 
        guiSetVisible ( win, true ) 
        showCursor ( true ) 
end 
addEventHandler("onClientMarkerHit", marker, openGUI ) 
  
addEventHandler ("onClientGUIClick",root, function () 
    if (source == buttonCancel ) then 
         guiSetVisible ( win, false ) 
         showCursor ( false ) 
    elseif (source == buttonAccept ) then 
        guiSetVisible ( win, false ) 
        showCursor ( false ) 
        triggerServerEvent ("setTeam", lp) 
        setElementModel ( lp, 59 ) 
        drugsMarker = createMarker ( 2048, 1584, 10, "cylinder", 2.0, 255, 0, 0, 255 ) 
        createBlipAttachedTo ( drugsMarker, 41, 2, 255, 0, 0, 255, 0, 65535 ) 
        addEventHandler("onClientMarkerHit", drugsMarker, openDrugsGUI ) 
    end 
end 
) 
  
function invPed() 
cancelEvent() 
end 
addEventHandler("onClientPedDamage", ped, invPed) 
  
function openDrugsGUI ( p ) 
 if ( getElementType ( p ) == "player" and p == lp ) then 
  guiSetVisible ( drugsWindow, true ) 
  showCursor ( true ) 
 end 
end 
  
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == buttonCancelTwo ) then 
            guiSetVisible ( drugsWindow, false ) 
            showCursor ( false ) 
        elseif ( source == buttonBuy ) then 
            guiSetVisible ( drugsWindow, false ) 
            showCursor ( false ) 
            outputChatBox ( "Go to the marker to sell your drugs" ) 
            destroyElement ( drugsMarker ) 
            drugBought = guiGridListGetSelectedItem ( gridList ) 
            if ( drugBought == meth ) then 
                if ( getPlayerMoney ( ) >= 500000 ) then 
                    triggerServerEvent ( "takeMoney", lp, 500000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == cocaine ) then 
                if ( getPlayerMoney ( ) >= 50000 ) then 
                    triggerServerEvent ( "takeMoney", lp, 50000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == heroin ) then 
                if ( getPlayerMoney ( ) >= 25000 ) then 
                    triggerServerEvent ( "takeMoney", lp, 25000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == ecstasy ) then 
                if ( getPlayerMoney ( ) >= 15000 ) then 
                    triggerServerEvent ( "takeMoney", lp, 15000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            elseif ( drugBought == marijuana ) then 
                if ( getPlayerMoney ( ) >= 5000 ) then 
                    triggerServerEvent ( "takeMoney", lp, 5000 ) 
                else 
                    outputChatBox ( "You don't have enough money for that", 255, 0, 0 ) 
                end 
            end 
        end 
    end 
) 

SERVER

local CrimTeam = createTeam ( "Criminal" ) 
function takejob () 
  if ( CrimTeam ) then 
    outputChatBox ( "Go to the marker to buy drugs", source, 0, 255, 0 ) 
    setPlayerTeam(source, CrimTeam ) 
end 
end 
addEvent ( "setTeam", true ) 
addEventHandler ( "setTeam", root, takejob ) 
  
function moneyTake () 
outputChatBox ( "Go to the marker to sell your drugs", source ) 
end 
addEvent ("takeMoney", true) 
addEventHandler ( "takeMoney", root, moneyTake ) 
  

Still no money is taken from the player..

Also, it doesn't even check if the player has enough money or not, but it still outputs "Go to the marker to sell your drugs"...

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