Jump to content

Zombies - how to make a gui showing rank


Einheit-101

Recommended Posts

Hello Community.

I try to write a script to get the Zombie kills of a player and make a dxscoreboard tab showing the rank of the player. The more kills, the better your rank. (10 kills=rookie, 50 kills=soldier, etc.etc...) And, for example, if you are a rookie, you get instead of one wanted star a custom image showing your rank. Anyone helping me is very welcome.

Link to comment

Like in my ZA resource. Well, this isn't any requesting forum. You should check out my resource scripts. I know these are made by server-side texts, but you can get an idea of how to use it. You should use:

guiCreateLabel

onZombieWasted --> triggerClientEvent --> guiSetText

AT LEAST try it, using your brain and the wiki. Then, use /debugscript 3 and if something doesn't work, show us your code ;)

PS: We are a HELPING forum, NOT REQUEST forum

Link to comment

:::HERE IS THE CODE:::

It happens Nothing. No error messages.

server:

  
function onResourceStart(startedResource) 
if startedResource == getThisResource() then 
        call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") 
end 
end 
addEventHandler("onResourceStart", getRootElement(), onResourceStart) 
  
function killed( ammo, attacker, weapon, bodypart ) 
    if (attacker) then 
        if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then 
            if (getElementData (source, "zombie") == true) then 
                local oldRank = getAccountData ( attacker, "myRank" ) 
                setElementData ( attacker, "Rank", myRank  ) 
            end 
        end 
    end 
end 
addEventHandler("onPedWasted", resourceRoot, killed) 
  

Client:

  
addEvent( "onZombieWasted" ); 
addEventHandler( "onZombieWasted", getRootElement(), 
       function( killer ) 
    local player = getPlayerAccount ( killer ) 
    local myRank = getAccountData(player,"rank") 
    local zombieKills = getAccountData(player, "zombieKills") 
 if (myRank == "" or myRank == nil or myRank == false) then 
               myRank = "[1]PVT" 
         img = guiCreateStaticImage( 1100, 200, 60, 70, "rang/r1.png", false ) 
              end 
              if (zombieKills == "" or zombieKills == nil or zombieKills == false) then 
               zombieKills = 0 
           givePlayerMoney( killer, 25 ) 
    setAccountData (player,"zombieKills",zombieKills+1); 
    end 
              if look == nil then 
               look = 0 
               display = textCreateDisplay() 
               textDisplayAddObserver (display,killer) 
               rank = textCreateTextItem ("Rank: "..myRank,0.8,0.53,"medium",255,50,0,150,1.5) 
               textDisplayAddText (display,rank) 
              elseif look == 0 then 
               textItemSetText (rank,"Rank: "..myRank) 
               textItemSetText (rank,"Rank: "..myRank) 
              end 
  
local x,y = guiGetScreenSize() 
xpos = x/2 - 60/2+ 480 
ypos = y/2 - 60/2 + y/4.5 
  
if (getAccountData (player,"zombieKills") == 20) then 
                  setAccountData (player,"rank","[2]PFC") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Private First Class.") 
                  guiStaticImageLoadImage (img, "rang/r2.png" ) 
        elseif (getAccountData (player,"zombieKills") == 40) then 
                  setAccountData (player,"rank","[3]SPC") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Specialist.") 
                  guiStaticImageLoadImage (img, "rang/r3.png" ) 
        elseif (getAccountData (player,"zombieKills") == 100) then 
                  setAccountData (player,"rank","[4]CPL") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Corporal.") 
                  guiStaticImageLoadImage (img, "rang/r4.png" ) 
        elseif (getAccountData (player,"zombieKills") == 200) then 
                  setAccountData (player,"rank","[5]SGT") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Sergeant.") 
                  guiStaticImageLoadImage (img, "rang/r5.png" ) 
        elseif (getAccountData (player,"zombieKills") == 350) then 
                  setAccountData (player,"rank","[6]SSG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Staff Sergeant.") 
                  guiStaticImageLoadImage (img, "rang/r6.png" ) 
        elseif (getAccountData (player,"zombieKills") == 600) then 
          setAccountData (player,"rank","[7]SFC") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Sergeant First Class.") 
                  guiStaticImageLoadImage (img, "rang/r7.png" ) 
        elseif (getAccountData (player,"zombieKills") == 900) then 
          setAccountData (player,"rank","[8]MSG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Master Sergeant.") 
                  guiStaticImageLoadImage (img, "rang/r8.png" ) 
        elseif (getAccountData (player,"zombieKills") == 1500) then 
          setAccountData (player,"rank","[9]1SG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a First Sergeant.") 
                  guiStaticImageLoadImage (img, "rang/r9.png" ) 
        elseif (getAccountData (player,"zombieKills") == 2000) then 
          setAccountData (player,"rank","[10]SGM") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Sergeant Major.") 
                  guiStaticImageLoadImage (img, "rang/r10.png" ) 
        elseif (getAccountData (player,"zombieKills") == 3000) then 
          setAccountData (player,"rank","[11]CSM") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Command Sergeant Major.") 
                  guiStaticImageLoadImage (img, "rang/r11.png" ) 
        elseif (getAccountData (player,"zombieKills") == 4000) then 
          setAccountData (player,"rank","[12]SMA") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Sergeant Major of the Army.") 
                  guiStaticImageLoadImage (img, "rang/r12.png" ) 
        elseif (getAccountData (player,"zombieKills") == 5500) then 
          setAccountData (player,"rank","[13]2LT") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Second Lieutenant.") 
                  guiStaticImageLoadImage (img, "rang/r13.png" ) 
        elseif (getAccountData (player,"zombieKills") == 7000) then 
          setAccountData (player,"rank","[14]1LT") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a First Lieutenant.") 
                  guiStaticImageLoadImage (img, "rang/r14.png" ) 
        elseif (getAccountData (player,"zombieKills") == 9000) then 
          setAccountData (player,"rank","[15]CPT") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Captain.") 
                  guiStaticImageLoadImage (img, "rang/r15.png" ) 
        elseif (getAccountData (player,"zombieKills") == 11500) then 
          setAccountData (player,"rank","[16]MAJ") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Major.") 
                  guiStaticImageLoadImage (img, "rang/r16.png" ) 
        elseif (getAccountData (player,"zombieKills") == 14000) then 
          setAccountData (player,"rank","[17]LTC") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Lieutenant Colonel.") 
                  guiStaticImageLoadImage (img, "rang/r17.png" ) 
        elseif (getAccountData (player,"zombieKills") == 17000) then 
          setAccountData (player,"rank","[18]COL") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Colonel.") 
                  guiStaticImageLoadImage (img, "rang/r18.png" ) 
        elseif (getAccountData (player,"zombieKills") == 21000) then 
          setAccountData (player,"rank","[19]BG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Brigadier General.") 
                  guiStaticImageLoadImage (img, "rang/r19.png" ) 
        elseif (getAccountData (player,"zombieKills") == 26000) then 
          setAccountData (player,"rank","[20]MG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Major General.") 
                  guiStaticImageLoadImage (img, "rang/r20.png" ) 
        elseif (getAccountData (player,"zombieKills") == 33000) then 
          setAccountData (player,"rank","[21]LTG") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a Lieutenant General.") 
                  guiStaticImageLoadImage (img, "rang/r21.png" ) 
        elseif (getAccountData (player,"zombieKills") == 40000) then 
          setAccountData (player,"rank","[22]GEN") 
                  outputChatBox (..getPlayerName(killer).." has been promoted. He is now a General.") 
                  guiStaticImageLoadImage (img, "rang/r22.png" ) 
        elseif (getAccountData (player,"zombieKills") == 50000) then 
          setAccountData (player,"rank","[23]GA") 
                  outputChatBox (..getPlayerName(killer).." has reached the highest rank! He is General of the Army!") 
                  guiStaticImageLoadImage (img, "rang/r23.png" ) 
              end 
          end 
      ) 
       end 
) 
  

Link to comment

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