bartje01 Posted June 13, 2012 Share Posted June 13, 2012 Hey all, I want to get a screen in my server side script. How can I do this? I putted this in guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) but it's'client side only. It has to be in my server. Link to comment
X-SHADOW Posted June 13, 2012 Share Posted June 13, 2012 Use this on ServerSide, [url=https://wiki.multitheftauto.com/wiki/TriggerClientEvent]https://wiki.multitheftauto.com/wiki/TriggerClientEvent[/url] Link to comment
bartje01 Posted June 13, 2012 Author Share Posted June 13, 2012 Hmm. I tried. Can't come out.. Client function achiev ( ) guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) end addEvent( "achievement", true ) addEventHandler( "achievement", getRootElement(), achiev ) server function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if not zombieKills then setAccountData(account,"Zombie kills",0) end setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) if getElementData(killer, "Zombie kills") == 5 then triggerClientEvent ( "achievement", getRootElement(), "Hello World!" ) end end Please help me. Link to comment
Stanley Sathler Posted June 13, 2012 Share Posted June 13, 2012 You're calling the "achievement" event and sending an argument "Hello World". But your function achiev() doesn't accept arguments, then you do not need use it. Try use: triggerClientEvent("achievement", getRootElement()) And please, tabulate your code. It's horrible. Link to comment
Al3grab Posted June 13, 2012 Share Posted June 13, 2012 You're calling the "achievement" event and sending an argument "Hello World". But your function achiev() doesn't accept arguments, then you do not need use it.Try use: triggerClientEvent("achievement", getRootElement()) And please, tabulate your code. It's horrible. Using getRootElement() will trigger the event for all players .. function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") or 0 setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) if getElementData(killer, "Zombie kills") == 5 then triggerClientEvent ( killer,"achievement", killer ) end end Link to comment
bartje01 Posted June 13, 2012 Author Share Posted June 13, 2012 You're calling the "achievement" event and sending an argument "Hello World". But your function achiev() doesn't accept arguments, then you do not need use it.Try use: triggerClientEvent("achievement", getRootElement()) And please, tabulate your code. It's horrible. Using getRootElement() will trigger the event for all players .. function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") or 0 setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) if getElementData(killer, "Zombie kills") == 5 then triggerClientEvent ( killer,"achievement", killer ) end end Now this is my client side: function achiev ( ) guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) outputChatBox ( "test" ) end addEvent( "achievement", true ) addEventHandler( "achievement", getRootElement(), achiev ) The img still doesn't show up :l. Link to comment
Stanley Sathler Posted June 13, 2012 Share Posted June 13, 2012 You putted the path of the image in your meta.xml? And it is correct? Show us your meta.xml, if possible. The outputChatBox() function is called (when you call event)? Link to comment
bartje01 Posted June 13, 2012 Author Share Posted June 13, 2012 <meta> <settings> <setting name="*MaxZombies" value="[100]" /> <!--maximum allowed zombies --> <setting name="*StreamMethod" value="[1]" /> <!-- 1 to constantly stream zombies, 0 to only allow zombies to spawn via createZombie function, 2 to only allow spawning at set spawnpoints --> <setting name="*Speed" value="[1]" /> <!-- 0 is slowest, 1 is normal, 2 faster --> </settings> <info author="Slothman" name="Zday script" version="3.0.1" type="script" description="Zombie Infestation script" edf:definition="edf/zombies.edf"/>/> <script src="zombie_server.lua" /> <script src="teams.lua" /> <script src="zombiekill_server.lua" /> <script src="saver.lua" /> <script src="level.lua" /> <script src="zombie_client.lua" type="client"/> <script type="client" src="Client_SW.lua"/> <script type="server" src="Server_SW.lua"/> <file src="images/1.png"/> <file src="images/16.png"/> <file src="images/22.png"/> <file src="images/23.png"/> <file src="images/24.png"/> <file src="images/25.png"/> <file src="images/26.png"/> <file src="images/27.png"/> <file src="images/28.png"/> <file src="images/29.png"/> <file src="images/30.png"/> <file src="images/31.png"/> <file src="images/32.png"/> <file src="images/33.png"/> <file src="images/34.png"/> <file src="zombiewood.png" /> <file src="skins/13.txd" /> <file src="skins/22.txd" /> <file src="skins/56.txd" /> <file src="skins/67.txd" /> <file src="skins/68.txd" /> <file src="skins/69.txd" /> <file src="skins/70.txd" /> <file src="skins/84.txd" /> <file src="skins/92.txd" /> <file src="skins/97.txd" /> <file src="skins/105.txd" /> <file src="skins/107.txd" /> <file src="skins/108.txd" /> <file src="skins/111.txd" /> <file src="skins/126.txd" /> <file src="skins/127.txd" /> <file src="skins/128.txd" /> <file src="skins/152.txd" /> <file src="skins/162.txd" /> <file src="skins/167.txd" /> <file src="skins/188.txd" /> <file src="skins/192.txd" /> <file src="skins/195.txd" /> <file src="skins/206.txd" /> <file src="skins/209.txd" /> <file src="skins/212.txd" /> <file src="skins/229.txd" /> <file src="skins/230.txd" /> <file src="skins/258.txd" /> <file src="skins/264.txd" /> <file src="skins/274.txd" /> <file src="skins/277.txd" /> <file src="skins/280.txd" /> <file src="skins/287.txd" /> <file src="sounds/mgroan1.ogg" /> <file src="sounds/mgroan2.ogg" /> <file src="sounds/mgroan3.ogg" /> <file src="sounds/mgroan4.ogg" /> <file src="sounds/mgroan5.ogg" /> <file src="sounds/mgroan6.ogg" /> <file src="sounds/mgroan7.ogg" /> <file src="sounds/mgroan8.ogg" /> <file src="sounds/mgroan9.ogg" /> <file src="sounds/mgroan10.ogg" /> <file src="edf/zombiespawn.png" /> <file src="get5zombiekills.png" /> <export function="createZombie" type="server"/> <export function="isPedZombie" type="server"/> </meta> And yes, the outputchatbox works. Link to comment
X-SHADOW Posted June 14, 2012 Share Posted June 14, 2012 Try This and type /debugscript to see errors .. ---serverSide function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") or 0 setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) if getElementData(killer, "Zombie kills") == 5 then triggerClientEvent ( killer,"achievement", killer ) end end --clientSide addEvent('achievement', true) addEventHandler('achievement', root, function() guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) end) Link to comment
Guest Guest4401 Posted June 14, 2012 Share Posted June 14, 2012 guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) How do you expect the image to appear if you are using absolute positions but you have defined the positioning as relative? Change guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) to guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) Link to comment
bartje01 Posted June 14, 2012 Author Share Posted June 14, 2012 guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) How do you expect the image to appear if you are using absolute positions but you have defined the positioning as relative? Change guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", true ) to guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) Thankyou, works fine now. But.. how can I set a timer that it stays for two seconds? Link to comment
Guest Guest4401 Posted June 14, 2012 Share Posted June 14, 2012 local image = guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) setTimer(destroyElement,2000,1,image) 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