Jump to content

Screen in server side


bartje01

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted
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 
  

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

Posted

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

Posted

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) 

Guest Guest4401
Posted
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 ) 

Posted
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? :oops:

Guest Guest4401
Posted
local image = guiCreateStaticImage( 20, 200, 100, 100, "get5zombiekills.png", false ) 
setTimer(destroyElement,2000,1,image) 

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