Jump to content

تعديل على الكود


nony

Recommended Posts

السلام عليكم ورحمه الله وبركاته

يا شباب

عندي كود ارسال الفلوس مايجي فيه اسماء الاعبين

ذا الكود

client.lua

---------------------------------------------------------------------------------------  
tab7 = guiCreateTab("Send Money",tabPanel) 
---------------------------------------------------------------------------------------- 
  
  
setTimer( 
    function() 
        playerList = guiCreateGridList(2, 2, 250, 490, false, tab7) 
            guiGridListSetSelectionMode(playerList, 2) 
            local cl = guiGridListAddColumn(playerList, "Players List ...", 0.85) 
                if ( cl and guiGetVisible(gui["_root"]) == true ) then 
                    for _,name in ipairs(getElementsByType("player")) do 
                     local rw = guiGridListAddRow(playerList) 
                     guiGridListSetItemText(playerList, rw, cl, getPlayerName(name), false, false) 
                    end 
        addEventHandler("onClientGUIClick", playerList, onClickPlayerName) 
                end 
    end 
,4000,0) 
  
nameEdit = guiCreateEdit(290,50,200,30,"",false,tab7) 
 player = guiCreateLabel(365,30,300,100,' player: ',false,tab7) 
guiSetText ( player, getPlayerPing(source)) 
guiLabelSetColor(player,255,255,100)   
  
amountEdit = guiCreateEdit(335,115,100,30,"",false,tab7) 
 money = guiCreateLabel(360,95,300,100,' money: ',false,tab7) 
guiSetText ( money, getPlayerPing(source)) 
guiLabelSetColor(money,255,255,100)   
  
sendBTN = guiCreateButton(320,165,130,36, "send", false,tab7) 
  
  
  
  
function onClickPlayerName () 
  local name = guiGridListGetItemText(playerList, guiGridListGetSelectedItem(playerList), 1) 
  guiSetText(nameEdit, name) 
end 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function() 
       if ( source == sendBTN ) then 
         playerNick = guiGetText(nameEdit) 
         amount = guiGetText(amountEdit) 
         triggerServerEvent("onSendMoney", getLocalPlayer(), playerNick, amount) 
       end 
end) 
  
  

server.lua

----------------------------------------- 
  
  
  
addEvent("onSendMoney", true) 
addEventHandler("onSendMoney", getRootElement(), 
 function(who, player) 
   local money = getPlayerMoney(source) 
    if tonumber(player) >= 200 then 
        if tonumber(player) <= money then 
            toWho = getPlayerFromName(who) 
                if toWho ~= false then 
                    givePlayerMoney(toWho, player) 
                    takePlayerMoney(source, player) 
                    name = getPlayerName(source) 
                    outputChatBox("* You have given money amount of: #00ff00$" .. player .. " #0099ccto: #ff0000" .. who, source, 0, 150, 255, true) 
                    outputChatBox("* ".. name .. " #ff0000has given you money amount of: #00ff00$" .. player .. " #ff0000!", toWho, 255, 0, 0, true) 
                else 
                    outputChatBox("* Player did not exist !", source, 255, 0, 0) 
                end 
        else 
            outputChatBox("* you dont have enough money !", source, 255, 0, 0) 
        end 
    else 
        outputChatBox("* the Less amount must be #00ff00$200 !", source, 255, 0, 0) 
    end 
 end 
) 
  
  
------------------------------------------------ 

وش الخطأ في الكود؟؟؟ :mrgreen:

Link to comment

ججرب ذا

-- Client Side

--------------------------------------------------------------------------------------- 
tab7 = guiCreateTab("Send Money",tabPanel) 
---------------------------------------------------------------------------------------- 
  
  
setTimer( 
    function() 
        playerList = guiCreateGridList(2, 2, 250, 490, false, tab7) 
            guiGridListSetSelectionMode(playerList, 2) 
            local cl = guiGridListAddColumn(playerList, "Players List ...", 0.85) 
                if ( cl and guiGetVisible(tabPanel) == true ) then 
                    for _,name in ipairs(getElementsByType("player")) do 
                     local rw = guiGridListAddRow(playerList) 
                     guiGridListSetItemText(playerList, rw, cl, getPlayerName(name), false, false) 
                    end 
        addEventHandler("onClientGUIClick", playerList, onClickPlayerName) 
                end 
    end 
,4000,0) 
  
nameEdit = guiCreateEdit(290,50,200,30,"",false,tab7) 
 player = guiCreateLabel(365,30,300,100,' player: ',false,tab7) 
guiSetText ( player, getPlayerPing(source)) 
guiLabelSetColor(player,255,255,100)   
  
amountEdit = guiCreateEdit(335,115,100,30,"",false,tab7) 
 money = guiCreateLabel(360,95,300,100,' money: ',false,tab7) 
guiSetText ( money, getPlayerPing(source)) 
guiLabelSetColor(money,255,255,100)   
  
sendBTN = guiCreateButton(320,165,130,36, "send", false,tab7) 
  
  
  
  
function onClickPlayerName () 
  local name = guiGridListGetItemText(playerList, guiGridListGetSelectedItem(playerList), 1) 
  guiSetText(nameEdit, name) 
end 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function() 
       if ( source == sendBTN ) then 
         playerNick = guiGetText(nameEdit) 
         amount = guiGetText(amountEdit) 
         triggerServerEvent("onSendMoney", getLocalPlayer(), playerNick, amount) 
       end 
end) 

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