Xeno Posted January 22, 2012 Posted January 22, 2012 Is there a function that Is cliented sided that does the same as getAccountData? LIke how would I get something like this... local zombieKills = getAccountData(account,"Zombie kills") Please help, thanks, Xeno.
Castillo Posted January 22, 2012 Posted January 22, 2012 These functions are only available server-side.
bandi94 Posted January 22, 2012 Posted January 22, 2012 nope use triggerServerEvent() triggerClientEvent()
Xeno Posted January 22, 2012 Author Posted January 22, 2012 Well how would I transfer "zombieKills" to clientside?
Xeno Posted January 22, 2012 Author Posted January 22, 2012 Well how would I transfer "zombieKills" to clientside?
bandi94 Posted January 22, 2012 Posted January 22, 2012 server side function sendkillstoclient() local zombieKills = getAccountData(getPlayerAccount(source),"Zombie kills") triggerClientEvent(source,"kills",source,zombieKills ) end addEvent("ask",true) addEventHandler("ask",getRootElement(),sendkillstoclient) client side function zombikills(kill) outputChatBox("You have: "..kill.." kill's") end addEvent("kills",true) addEventHandler("kills",getRootElement(),zombikills) function ask() triggerServerEvent("ask",getLocalPlayer()) end addCommandHandler("zombikills",ask)
Castillo Posted January 22, 2012 Posted January 22, 2012 nope use triggerServerEvent() triggerClientEvent() They still are server-side only, these two functions are used to send/receive information.
Kenix Posted January 23, 2012 Posted January 23, 2012 Xeno,Use setElementData for sync client side <-> server side. It's better. Example: Server addEvent( "data:event",true ) addEventHandler( "onPlayerLogin",root, function( ) local ac = getPlayerAccount( soruce ) if ac then if not isGuestAccount( ac ) then setElementData( source,"Zkills", tonumber( getAccountData( acc,"Zombie kills" ) ) or 0 ) end end end ) addEventHandler( "onPlayerQuit",root, function( ) local ac = getPlayerAccount( soruce ) if ac then if not isGuestAccount( ac ) then setAccountData( ac,"Zombie kills", tonumber( getElementData( source,"Zkills" ) ) or 0 ) end end end ) addEventHandler( "data:event",root, function( t,v ) setElementData( source,t,v ) end ) Client local lvl = { img = { [50] = "Newbie!", [500] = "Normal", [1000] = "Pro" }, points = { [50] = true, [500] = true, [1000] = true } } function _setElementData( el,t,v ) if isElement( el ) and type( t ) == "string" and v then return triggerServerEvent( "data:event",el,t,v ) end return false end addEventHandler( "onClientPedWasted",root, function( killer ) if getElementType( killer ) == "player" and getElementType( source ) == "ped" then _setElementData( killer,"Zkills",tonumber( getElementData( killer,"Zkills" ) or 0 ) + 1 ) if lvl["points"][ tonumber( getElementData( killer,"Zkills" ) or 0 ) ] then dxDrawText( tostring( lvl["img"][ tonumber( getElementData( killer,"Zkills" ) or 0 ) ] ),200,200,200,200,tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) end outputChatBox( "You killing: "..tostring( getElementData( killer,"Zkills" ) or 0 ).." zombies!" ) end end ) Here's an example we have.
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