-.Paradox.- Posted June 7, 2014 Share Posted June 7, 2014 Hello guys, i have a little problem, when i kill a zombie, It appears a text showing how much i earned, but it appear for all players, and it suppose to appear only for who killed the zombie, here is my code: Server addEvent( "onZombieWasted" , true) addEventHandler( "onZombieWasted", getRootElement(), function( killer ) local money = 500 givePlayerMoney( killer, tonumber(money)) triggerClientEvent("onClientZombieWasted", killer, money) end) Client local x,y = guiGetScreenSize() function onTest() dxDrawText("+"..tostring(money), x*1211/1366, y*51/768, x*1351/1366, y*77/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1211/1366, y*49/768, x*1351/1366, y*75/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1209/1366, y*51/768, x*1349/1366, y*77/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1209/1366, y*49/768, x*1349/1366, y*75/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1210/1366, y*50/768, x*1350/1366, y*76/768, tocolor(22, 131, 38, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) --for i=1, 18 do --dxDrawText("A zombie got killed ".. i, x*0.2, 0 - y*0.03 + (y*0.05 * i),x,y,tocolor(255,255,255,255)) --end end addEvent("onClientZombieWasted", true) addEventHandler( "onClientZombieWasted", root, function(mon) if not isTimer(moneyTimer) then moneyTimer = setTimer(function() removeEventHandler("onClientRender", root, onTest) end, 2000, 1) money = mon addEventHandler("onClientRender", root, onTest) else money = (money + mon) resetTimer(moneyTimer) end end) Link to comment
Price. Posted June 7, 2014 Share Posted June 7, 2014 uhm try defining the "killer" Client: local attacker = getPlayerName( killer ) local playeraccount = getPlayerAccount ( killer ) ofc you can change local and add it to server side if you want Link to comment
Price. Posted June 7, 2014 Share Posted June 7, 2014 just try it, its gonna be specified for the "account" I have a similar code of police and receiving money. Link to comment
MIKI785 Posted June 7, 2014 Share Posted June 7, 2014 The first argument in the triggerClientEvent is optional and is the element it will get sent to. Its root by default so just put killer before the name of the event and that should do it. Link to comment
Price. Posted June 7, 2014 Share Posted June 7, 2014 oh yes, didn't check the trigger client event correctly, as MIKI said should be like this triggerClientEvent( killer, "onClientZombieWasted", money) Link to comment
Max+ Posted June 8, 2014 Share Posted June 8, 2014 -- no Need for local Money on Server . . ---ClinetSide , function onTest() local x,y = guiGetScreenSize() local money = getPlayerMoney (localPlayer) dxDrawText("+"..tostring(money), x*1211/1366, y*51/768, x*1351/1366, y*77/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1211/1366, y*49/768, x*1351/1366, y*75/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1209/1366, y*51/768, x*1349/1366, y*77/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1209/1366, y*49/768, x*1349/1366, y*75/768, tocolor(0, 0, 0, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) dxDrawText("+"..tostring(money), x*1210/1366, y*50/768, x*1350/1366, y*76/768, tocolor(22, 131, 38, 255), 1.00, "pricedown", "left", "top", false, false, true, false, false) for i=1, 18 do dxDrawText("A zombie got killed ".. i, x*0.2, 0 - y*0.03 + (y*0.05 * i),x,y,tocolor(255,255,255,255)) end end addEvent("onClientZombieWasted", true) addEventHandler( "onClientZombieWasted", root, function(mon) if not isTimer(moneyTimer) then moneyTimer = setTimer(function() removeEventHandler("onClientRender", root, onTest) end, 2000, 1) money = mon addEventHandler("onClientRender",root, onTest) else money = (money + mon) resetTimer(moneyTimer) end end) ---ServerSide , addEvent( "onZombieWasted" , true) addEventHandler( "onZombieWasted", getRootElement(), function( attacker ) if ( getElementType ( attacker ) == "player" ) and ( getElementType ( source ) == "ped" ) then givePlayerMoney(attacker, 500) triggerClientEvent(attacker, 'onClientZombieWasted', attacker) end end ) Link to comment
-.Paradox.- Posted June 8, 2014 Author Share Posted June 8, 2014 The first argument in the triggerClientEvent is optional and is the element it will get sent to. Its root by default so just put killer before the name of the event and that should do it. MIKI785 Thank you. Max, I prefer doing it in my way. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now