Jump to content

takePlayerMoney help


-stolka-

Recommended Posts

why it doesnt teke player's money? line 49

theMarker = createMarker(2144.6176757813,-1688.2725830078,14.0859375, "cylinder", 2, 204, 0, 204,170) 
  
  
 GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
      
    function guiMyCwindow(w,h,t) 
      local x,y = guiGetScreenSize() 
      return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
    end 
      
    drugWindow = guiMyCwindow(301,250,"Buy Drugs") 
    guiSetVisible(drugWindow, false) 
     
    GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,drugWindow) 
    GUIEditor_Button[1] = guiCreateButton(179,200,110,36,"Cancel",false,drugWindow) 
    GUIEditor_Label[2] = guiCreateLabel(19,33,273,50,"Weed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[2], 0,255,0 ) 
    GUIEditor_Label[3] = guiCreateLabel(19,50,273,50,"Speed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[3], 204,0,204 ) 
    GUIEditor_Label[4] = guiCreateLabel(19,67,273,50,"Eroine ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[4], 255,255,0 ) 
    GUIEditor_Label[5] = guiCreateLabel(19,84,273,50,"LSD ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[5], 0,0,255 ) 
    GUIEditor_Label[6] = guiCreateLabel(19,101,273,50,"God ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[6], 255,0,0 ) 
    GUIEditor_Button[2] = guiCreateButton(95,33,70,15,"1000$",false,drugWindow) 
    GUIEditor_Button[3] = guiCreateButton(95,50,70,15,"1500$",false,drugWindow) 
    GUIEditor_Button[4] = guiCreateButton(95,67,70,15,"1200$",false,drugWindow) 
    GUIEditor_Button[5] = guiCreateButton(95,84,70,15,"800$",false,drugWindow) 
    GUIEditor_Button[6] = guiCreateButton(95,101,70,15,"2000$",false,drugWindow) 
  
function openDrugGui ( localPlayer ) 
       guiSetVisible(drugWindow, true) 
       showCursor(true) 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(), openDrugGui ) 
   
function removeDrugWindow() 
 guiSetVisible(drugWindow, false) 
 showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , removeDrugWindow, false) 
  
function buyWeed(localPlayer) 
 local pMoney = getPlayerMoney(localPlayer) 
 if ( pMoney > 1000 ) then 
  takePlayerMoney(localPlayer, 1000) 
 end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[2] , buyWeed, false) 

Link to comment

Client:

theMarker = createMarker(2144.6176757813,-1688.2725830078,14.0859375, "cylinder", 2, 204, 0, 204,170) 
  
  
 GUIEditor_Button = {} 
    GUIEditor_Memo = {} 
    GUIEditor_Label = {} 
      
    function guiMyCwindow(w,h,t) 
      local x,y = guiGetScreenSize() 
      return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
    end 
      
    drugWindow = guiMyCwindow(301,250,"Buy Drugs") 
    guiSetVisible(drugWindow, false) 
    
    GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,drugWindow) 
    GUIEditor_Button[1] = guiCreateButton(179,200,110,36,"Cancel",false,drugWindow) 
    GUIEditor_Label[2] = guiCreateLabel(19,33,273,50,"Weed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[2], 0,255,0 ) 
    GUIEditor_Label[3] = guiCreateLabel(19,50,273,50,"Speed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[3], 204,0,204 ) 
    GUIEditor_Label[4] = guiCreateLabel(19,67,273,50,"Eroine ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[4], 255,255,0 ) 
    GUIEditor_Label[5] = guiCreateLabel(19,84,273,50,"LSD ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[5], 0,0,255 ) 
    GUIEditor_Label[6] = guiCreateLabel(19,101,273,50,"God ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[6], 255,0,0 ) 
    GUIEditor_Button[2] = guiCreateButton(95,33,70,15,"1000$",false,drugWindow) 
    GUIEditor_Button[3] = guiCreateButton(95,50,70,15,"1500$",false,drugWindow) 
    GUIEditor_Button[4] = guiCreateButton(95,67,70,15,"1200$",false,drugWindow) 
    GUIEditor_Button[5] = guiCreateButton(95,84,70,15,"800$",false,drugWindow) 
    GUIEditor_Button[6] = guiCreateButton(95,101,70,15,"2000$",false,drugWindow) 
  
function openDrugGui ( localPlayer ) 
       guiSetVisible(drugWindow, true) 
       showCursor(true) 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(), openDrugGui ) 
  
function removeDrugWindow() 
 guiSetVisible(drugWindow, false) 
 showCursor(false) 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[1] , removeDrugWindow, false) 
  
function buyWeed(localPlayer) 
 local pMoney = getPlayerMoney(localPlayer) 
 if ( pMoney > 1000 ) then 
  triggerServerEvent("takemoney",localPlayer) 
 end 
end 
addEventHandler("onClientGUIClick", GUIEditor_Button[2] , buyWeed, false) 

Server:

function moneyTake() 
takePlayerMoney(source,1000) 
end 
addEvent("takemoney",true) 
addEventHandler("takemoney",getRootElement(),moneyTake) 

Link to comment
theMarker = createMarker(2144.6176757813,-1688.2725830078,14.0859375, "cylinder", 2, 204, 0, 204,170) 
  
  
GUIEditor_Button = {} 
GUIEditor_Memo = {} 
GUIEditor_Label = {} 
      
function guiMyCwindow(w,h,t) 
    local x,y = guiGetScreenSize() 
    return guiCreateWindow((x-w)/2,(y-h)/2,w,h,t,false) 
end 
      
    drugWindow = guiMyCwindow(301,250,"Buy Drugs") 
    guiSetVisible(drugWindow, false) 
    
    GUIEditor_Label[1] = guiCreateLabel(193,-103,5,5,"",false,drugWindow) 
    GUIEditor_Button[1] = guiCreateButton(179,200,110,36,"Cancel",false,drugWindow) 
    GUIEditor_Label[2] = guiCreateLabel(19,33,273,50,"Weed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[2], 0,255,0 ) 
    GUIEditor_Label[3] = guiCreateLabel(19,50,273,50,"Speed ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[3], 204,0,204 ) 
    GUIEditor_Label[4] = guiCreateLabel(19,67,273,50,"Eroine ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[4], 255,255,0 ) 
    GUIEditor_Label[5] = guiCreateLabel(19,84,273,50,"LSD ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[5], 0,0,255 ) 
    GUIEditor_Label[6] = guiCreateLabel(19,101,273,50,"God ( x 5 )",false,drugWindow) 
      guiLabelSetColor( GUIEditor_Label[6], 255,0,0 ) 
    GUIEditor_Button[2] = guiCreateButton(95,33,70,15,"1000$",false,drugWindow) 
    GUIEditor_Button[3] = guiCreateButton(95,50,70,15,"1500$",false,drugWindow) 
    GUIEditor_Button[4] = guiCreateButton(95,67,70,15,"1200$",false,drugWindow) 
    GUIEditor_Button[5] = guiCreateButton(95,84,70,15,"800$",false,drugWindow) 
    GUIEditor_Button[6] = guiCreateButton(95,101,70,15,"2000$",false,drugWindow) 
  
function openDrugGui ( element ) 
    if ( source == theMarker ) then 
        if ( element == localPlayer ) then 
            guiSetVisible( drugWindow, true ) 
            showCursor( true ) 
        end 
    end 
end 
addEventHandler ( "onClientMarkerHit", resourceRoot, openDrugGui ) 
  
function buyWeed( ) 
    if ( source == GUIEditor_Button[ 1 ] ) then 
        guiSetVisible( drugWindow, false ) 
        showCursor( false ) 
    elseif ( source == GUIEditor_Button[ 2 ] ) then 
        triggerServerEvent( "takemoney", localPlayer ) 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, buyWeed ) 

addEvent( "takemoney", true ) 
function moneyTake( ) 
    if ( getPlayerMoney( source ) > 1000 ) then 
        takePlayerMoney( source, 1000 ) 
    else  
        "You don't have money" 
    end 
end 
addEventHandler( "takemoney", getRootElement(), moneyTake ) 

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