Jump to content

i need help again :)


Erhabi

Recommended Posts

Posted

hi all

I have one question

How do I give money to another player using givePlayerMoney code in client.lua???

In other words,

how can i use givePlayerMoney in client.lua to give another player?

208892221.jpg

Posted

don't use givePlayerMoney or takePlayerMoney or setPlayerMoney on client-side at all !

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

function gui ( )
       window = guiCreateWindow ( 0.4, 0.3, 0.3, 0.4, "Welcome "..getPlayerName ( getLocalPlayer () ), true )
       mymoney = guiCreateLabel ( 0.25, 0.10, 0.8, 0.12, "Your money: $"..getPlayerMoney ( source ), true, window )
       guiCreateLabel ( 0.1, 0.25, 0.8, 0.12, "Player:", true, window )
       guiCreateLabel ( 0.1, 0.44, 0.8, 0.12, "Money:", true, window )
       editBox1 = guiCreateEdit( 0.3, 0.26, 0.7, 0.12, "", true, window )
       editBox2 = guiCreateEdit( 0.3, 0.42, 0.7, 0.12, "", true, window )
       give = guiCreateButton ( 0.1, 0.58, 0.8, 0.12, "Give!", true, window )
addEventHandler ( "onClientGUIClick", give, give1, false )
end
addEventHandler ( "onClientResourceStart", getRootElement(), gui )
--------------
function show_gui ( )
guiSetText ( mymoney, "Your money: $"..getPlayerMoney ( source ) )
guiSetText ( window, "Welcome "..getPlayerName ( getLocalPlayer () ) )
       if ( guiGetVisible ( window ) == true ) then
               guiSetVisible ( window, false )
               showCursor ( false )
       else
               guiSetVisible ( window, true )
               showCursor ( true )
       end
end
function close_gui ( )
     showCursor ( false )
     guiSetVisible ( window, false )
end
function Keys ( )
     bindKey ( "F7", "down", show_gui )
end
addEventHandler( "onClientResourceStart", getRootElement( ), Keys )
addEventHandler ( "onClientResourceStart", getRootElement(), close_gui )
---------------
function give1 ( )
eee = guiGetText ( editBox1 )
player1 = getPlayerFromName ( eee )
ddd = guiGetText ( editBox2 )
end
---------------

my problem how can i get player name from editBox1 and give him money

i can't give him money in client.lua :(

because i can't set player in givePlayerMoney if it in client.lua

Posted

karlis gave you an advice..

read about triggerServerEvent in wiki :)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

i read it and i know use it

but if i use it in editBox1 it does not work

please give me exp for editBox1 = guiCreateEdit to give another player

Posted
heeeeeeelp!!!!!

hey! you can't get help in 5 minutes :/ be patient..

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

BE PATIENT!!!

Here's the script.. Please visit in http://www.wiki.multitheftauto.com in future, i wont help you with this kind of cases if you dont go there.

okay ..

CLIENT-SIDE

(client.lua)

-- Please go to wiki.multitheftauto.com so i dont need to help you in future --
-- Here's working script --
-- Taalasmaa handles --
 
 
function gui ( )
       window = guiCreateWindow ( 0.4, 0.3, 0.3, 0.4, "Welcome "..getPlayerName ( getLocalPlayer () ), true )
       mymoney = guiCreateLabel ( 0.25, 0.10, 0.8, 0.12, "Your money: $"..getPlayerMoney ( source ), true, window )
guiCreateLabel ( 0.1, 0.25, 0.8, 0.12, "Player:", true, window )
guiCreateLabel ( 0.1, 0.44, 0.8, 0.12, "Money:", true, window )
       editBox1 = guiCreateEdit( 0.3, 0.26, 0.7, 0.12, "", true, window )
       editBox2 = guiCreateEdit( 0.3, 0.42, 0.7, 0.12, "", true, window )
       give = guiCreateButton ( 0.1, 0.58, 0.8, 0.12, "Give!", true, window )
addEventHandler ( "onClientGUIClick", give, give1, false )
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), gui )
--------------
function show_gui ( )
guiSetText ( mymoney, "Your money: $"..getPlayerMoney ( source ) )
guiSetText ( window, "Welcome "..getPlayerName ( getLocalPlayer () ) )
if ( guiGetVisible ( window ) == true ) then
guiSetVisible ( window, false )
showCursor ( false )
else
guiSetVisible ( window, true )
showCursor ( true )
end
end
function close_gui ( )
showCursor ( false )
guiSetVisible ( window, false )
end
function Keys ( )
bindKey ( "F7", "down", show_gui )
end
addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), Keys )
addEventHandler ( "onClientResourceStart",getResourceRootElement(getThisResource()), close_gui )
---------------
function give1 ( )
eee = guiGetText ( editBox1 )
ddd = guiGetText ( editBox2 )
triggerServerEvent ( "theMoney", getLocalPlayer(), eee,ddd ) -- This sends datas to the server where is the function --
end
---------------

SERVERSIDE

Example: (server.lua)

function giveThem ( userplayer,money ) -- The datas we just sent
local cash = getPlayerMoney(source) 
if (cash > tonumber(money)) then -- if player who is sending money got that much money that he want to send
moneyToGive = getPlayerFromName(userplayer) -- get the player who we want to give the moneys
if (moneyToGive ~= false) then -- if there player exist
givePlayerMoney(moneyToGive,money) -- give his money
name = getPlayerName(source) 
takePlayerMoney(source,money) -- take the money amount from the sender
outputChatBox("You've given money amount of: " .. money .. "$ for: " .. userplayer,source,255,255,0) -- just stuff you can change this --
outputChatBox(name .. " has given you money amount of: " .. money .. "$!",moneyToGive,255,255,0) -- the player who get the money will see this, can be changed too --
else
outputChatBox("Player did not exist",source,255,0,0) -- if there wasnt player
end
else
outputChatBox("You are trying to send amount of money that you even dont have?",source,255,0,0) -- if the sender does not have the amount of money he wants to send
end
end
addEvent( "theMoney", true )
addEventHandler( "theMoney", getRootElement(), giveThem )

Regards

Taalasmaa

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

Posted

No problem, but keep the wiki.multitheftauto.com in your mind.

http://www.sincitygaming.net - The next generation of gaming!

SinCity Gaming | UltiRace 24/7 - 188.165.199.162:22003

SinCity Gaming | Roleplay Gaming - Beta soon!

SinCity Gaming | Zombie Mode + - 188.165.199.162:22005

Instead of using ip: 188.165.199.162 you can use: sincitygaming.net

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