Einheit-101 Posted March 5, 2011 Share Posted March 5, 2011 Okay i know i`m getting annoying, but my brand new rank script for my server has some confusing errors. Nothing works exactly as it should. I have commented most of the functions that you know what they do. server function scorebrett() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") -- ON RESOURCE START SETUP call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do display = textCreateDisplay() textDisplayAddObserver (display,thePlayer) end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), scorebrett ) function killtherank(source) local player = getPlayerAccount ( source ) local myRank = getAccountData(player,"rank") setAccountData(player,"rank","[1]PVT") local zombieKills = getAccountData(player, "zombieKills") -- SET ALL DATA TO 0 (Doesnt work ) outputChatBox ("Account deleted.", client) zombieKills = 0 end addCommandHandler("killrank", killtherank) addEventHandler ("onPlayerJoin",getRootElement(), function (source) playerac = getPlayerAccount(source) look = nil local accountname = getAccountName(playerac) -- SET ELEMENT DATA TO IDENTIFY ADMINS if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then setElementData(client, "Admin") end end) addEvent("onZombieWasted") addEventHandler( "onZombieWasted", getRootElement(), function (killer) local player = getPlayerAccount ( killer ) local myRank = getAccountData(player,"rank") -- GET THE ACCOUNT local zombieKills = getAccountData(player, "zombieKills") if (myRank == "" or myRank == nil or myRank == false) then myRank = "[1]PVT" setElementData ( killer, "Rank", "[1]PVT") -- IF RANK DOESNT EXIST, MAKE RANK 1 end if (zombieKills == "" or zombieKills == nil or zombieKills == false) then zombieKills = 0 end if look == nil then look = 0 kills = textCreateTextItem ("Kills: "..zombieKills,0.8,0.5,"medium",255,255,255,255,1.5) -- CREATE THE TEXT ITEMS rank = textCreateTextItem ("Rank: "..myRank,0.8,0.53,"medium",255,255,255,255,1.5) textDisplayAddText (display,kills) textDisplayAddText (display,rank) elseif look == 0 then textItemSetText (kills,"Kills: "..zombieKills) -- SET THE TEXT FOR THE TEXTDISPLAY textItemSetText (rank,"Rank: "..myRank) end givePlayerMoney (killer, 25) setAccountData (player,"zombieKills",zombieKills+1) -- SET ZOMBIEKILLS +1 setElementData ( killer, "Zombie Kills", zombieKills+1) if (getAccountData (player,"zombieKills") == 20) then -- SET THE ACCOUNT & ELEMENT DATA FOR ZOMBIE KILLS setAccountData (player,"rank","[2]PFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Private First Class.") triggerClientEvent("r1", getRootElement()) elseif (getAccountData (player,"zombieKills") == 40) then setAccountData (player,"rank","[3]SPC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Specialist.") triggerClientEvent("r2", getRootElement()) elseif (getAccountData (player,"zombieKills") == 100) then setAccountData (player,"rank","[4]CPL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Corporal.") triggerClientEvent("r3", getRootElement()) elseif (getAccountData (player,"zombieKills") == 200) then setAccountData (player,"rank","[5]SGT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant.") triggerClientEvent("r4", getRootElement()) elseif (getAccountData (player,"zombieKills") == 350) then setAccountData (player,"rank","[6]SSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Staff Sergeant.") triggerClientEvent("r5", getRootElement()) elseif (getAccountData (player,"zombieKills") == 600) then setAccountData (player,"rank","[7]SFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant First Class.") triggerClientEvent("r6", getRootElement()) elseif (getAccountData (player,"zombieKills") == 900) then setAccountData (player,"rank","[8]MSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Master Sergeant.") triggerClientEvent("r7", getRootElement()) elseif (getAccountData (player,"zombieKills") == 1500) then setAccountData (player,"rank","[9]1SG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Sergeant.") triggerClientEvent("r8", getRootElement()) elseif (getAccountData (player,"zombieKills") == 1800) then setAccountData (player,"rank","[10]SGM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major.") triggerClientEvent("r9", getRootElement()) elseif (getAccountData (player,"zombieKills") == 2300) then setAccountData (player,"rank","[11]CSM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Command Sergeant Major.") triggerClientEvent("r10", getRootElement()) elseif (getAccountData (player,"zombieKills") == 3000) then setAccountData (player,"rank","[12]SMA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major of the Army.") triggerClientEvent("r11", getRootElement()) elseif (getAccountData (player,"zombieKills") == 4000) then setAccountData (player,"rank","[13]2LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Second Lieutenant.") triggerClientEvent("r12", getRootElement()) elseif (getAccountData (player,"zombieKills") == 5500) then setAccountData (player,"rank","[14]1LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Lieutenant.") triggerClientEvent("r13", getRootElement()) elseif (getAccountData (player,"zombieKills") == 7000) then setAccountData (player,"rank","[15]CPT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Captain.") triggerClientEvent("r14", getRootElement()) elseif (getAccountData (player,"zombieKills") == 9000) then setAccountData (player,"rank","[16]MAJ") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major.") triggerClientEvent("r15", getRootElement()) elseif (getAccountData (player,"zombieKills") == 11500) then setAccountData (player,"rank","[17]LTC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant Colonel.") triggerClientEvent("r16", getRootElement()) elseif (getAccountData (player,"zombieKills") == 14000) then setAccountData (player,"rank","[18]COL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Colonel.") triggerClientEvent("r17", getRootElement()) elseif (getAccountData (player,"zombieKills") == 17000) then setAccountData (player,"rank","[19]BG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Brigadier General.") triggerClientEvent("r18", getRootElement()) elseif (getAccountData (player,"zombieKills") == 21000) then setAccountData (player,"rank","[20]MG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major General.") triggerClientEvent("r19", getRootElement()) elseif (getAccountData (player,"zombieKills") == 26000) then setAccountData (player,"rank","[21]LTG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant General.") triggerClientEvent("r20", getRootElement()) elseif (getAccountData (player,"zombieKills") == 35000) then setAccountData (player,"rank","[22]GEN") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a General.") triggerClientEvent("r21", getRootElement()) elseif (getAccountData (player,"zombieKills") == 50000) then setAccountData (player,"rank","[23]GA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has reached the highest rank! He is General of the Army!") triggerClientEvent("r22", getRootElement()) end end ) Client function imagedraw() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix() for k, v in ipairs(getElementsByType("player")) do if(getElementData(v, "Admin") == true) then tx, ty, tz = getElementPosition(v) dist = math.sqrt((px - tx) ^ 2 + (py - ty) ^ 2 + (pz - tz) ^ 2) if dist < 30.0 then if isLineOfSightClear(px, py, pz, tx, ty, tz, true, false, false, true, false, false, getLocalPlayer()) then local sx, sy, sz = getPedBonePosition(v, 5) local x,y = getScreenFromWorldPosition(sx, sy, sz + 0.3) if x then dxDrawImage ( x, y, 50, 50, "rang/admin.png" ) -- DRAW A IMAGE ABOVE ADMIN`S HEAD end end end end end end addEventHandler("onClientRender",getRootElement(),imagedraw) local xp,yp = guiGetScreenSize() x = xp/2 - 100/2+ 500 y = yp/2 - 100/2 + yp/4.5 image1 = guiCreateStaticImage( x,y, 100, 100, "rang/r1.png", false ) addEvent("r1", true) function image2() guiStaticImageLoadImage( image1, "rang/r2.png" ) -- ADD EVENTS FOR NEW RANK PICTURES end addEvent("r2", true) function image3() guiStaticImageLoadImage( image1, "rang/r3.png" ) end addEvent("r3", true) function image4() guiStaticImageLoadImage( image1, "rang/r4.png" ) end addEvent("r4", true) function image5() guiStaticImageLoadImage( image1, "rang/r5.png" ) end addEvent("r5", true) function image6() guiStaticImageLoadImage( image1, "rang/r6.png" ) end addEvent("r6", true) function image7() guiStaticImageLoadImage( image1, "rang/r7.png" ) end addEvent("r7", true) function image8() guiStaticImageLoadImage( image1, "rang/r8.png" ) end addEvent("r8", true) function image9() guiStaticImageLoadImage( image1, "rang/r9.png" ) end addEvent("r9", true) function image10() guiStaticImageLoadImage( image1, "rang/r10.png" ) end addEvent("r10", true) function image11() guiStaticImageLoadImage( image1, "rang/r11.png" ) end addEvent("r11", true) function image12() guiStaticImageLoadImage( image1, "rang/r12.png" ) end addEvent("r12", true) function image13() guiStaticImageLoadImage( image1, "rang/r13.png" ) end addEvent("r13", true) function image14() guiStaticImageLoadImage( image1, "rang/r14.png" ) end addEvent("r14", true) function image15() guiStaticImageLoadImage( image1, "rang/r15.png" ) end addEvent("r15", true) function image16() guiStaticImageLoadImage( image1, "rang/r16.png" ) end addEvent("r16", true) function image17() guiStaticImageLoadImage( image1, "rang/r17.png" ) end addEvent("r17", true) function image18() guiStaticImageLoadImage( image1, "rang/r18.png" ) end addEvent("r18", true) function image19() guiStaticImageLoadImage( image1, "rang/r19.png" ) end addEvent("r19", true) function image20() guiStaticImageLoadImage( image1, "rang/r20.png" ) end addEvent("r20", true) function image21() guiStaticImageLoadImage( image1, "rang/r21.png" ) end addEvent("r21", true) function image22() guiStaticImageLoadImage( image1, "rang/r22.png" ) end addEvent("r22", true) function image23() guiStaticImageLoadImage( image1, "rang/r23.png" ) end addEventHandler( "r1", getResourceRootElement(), image2 ) -- ADD EVENT HANDLERS FOR THE NEW PICTURES addEventHandler( "r2", getResourceRootElement(), image3 ) addEventHandler( "r3", getResourceRootElement(), image4 ) addEventHandler( "r4", getResourceRootElement(), image5 ) addEventHandler( "r5", getResourceRootElement(), image6 ) addEventHandler( "r6", getResourceRootElement(), image7 ) addEventHandler( "r7", getResourceRootElement(), image8 ) addEventHandler( "r8", getResourceRootElement(), image9 ) addEventHandler( "r9", getResourceRootElement(), image10 ) addEventHandler( "r10", getResourceRootElement(), image11 ) addEventHandler( "r11", getResourceRootElement(), image12 ) addEventHandler( "r12", getResourceRootElement(), image13 ) addEventHandler( "r13", getResourceRootElement(), image14 ) addEventHandler( "r14", getResourceRootElement(), image15 ) addEventHandler( "r15", getResourceRootElement(), image16 ) addEventHandler( "r16", getResourceRootElement(), image17 ) addEventHandler( "r17", getResourceRootElement(), image18 ) addEventHandler( "r18", getResourceRootElement(), image19 ) addEventHandler( "r19", getResourceRootElement(), image20 ) addEventHandler( "r20", getResourceRootElement(), image21 ) addEventHandler( "r21", getResourceRootElement(), image22 ) addEventHandler( "r22", getResourceRootElement(), image23 ) Link to comment
Kenix Posted March 5, 2011 Share Posted March 5, 2011 Okay i know i`m getting annoying, but my brand new rank script for my server has some confusing errors. Nothing works exactly as it should. I have commented most of the functions that you know what they do.server function scorebrett() call(getResourceFromName("scoreboard"), "addScoreboardColumn", "Rank") -- ON RESOURCE START SETUP call(getResourceFromName("scoreboard"), "scoreboardAddColumn", "Zombie kills") local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do display = textCreateDisplay() textDisplayAddObserver (display,thePlayer) end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), scorebrett ) function killtherank(source) local player = getPlayerAccount ( source ) local myRank = getAccountData(player,"rank") setAccountData(player,"rank","[1]PVT") local zombieKills = getAccountData(player, "zombieKills") -- SET ALL DATA TO 0 (Doesnt work ) outputChatBox ("Account deleted.", client) zombieKills = 0 end addCommandHandler("killrank", killtherank) addEventHandler ("onPlayerJoin",getRootElement(), function (source) playerac = getPlayerAccount(source) look = nil local accountname = getAccountName(playerac) -- SET ELEMENT DATA TO IDENTIFY ADMINS if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then setElementData(client, "Admin") end end) addEvent("onZombieWasted") addEventHandler( "onZombieWasted", getRootElement(), function (killer) local player = getPlayerAccount ( killer ) local myRank = getAccountData(player,"rank") -- GET THE ACCOUNT local zombieKills = getAccountData(player, "zombieKills") if (myRank == "" or myRank == nil or myRank == false) then myRank = "[1]PVT" setElementData ( killer, "Rank", "[1]PVT") -- IF RANK DOESNT EXIST, MAKE RANK 1 end if (zombieKills == "" or zombieKills == nil or zombieKills == false) then zombieKills = 0 end if look == nil then look = 0 kills = textCreateTextItem ("Kills: "..zombieKills,0.8,0.5,"medium",255,255,255,255,1.5) -- CREATE THE TEXT ITEMS rank = textCreateTextItem ("Rank: "..myRank,0.8,0.53,"medium",255,255,255,255,1.5) textDisplayAddText (display,kills) textDisplayAddText (display,rank) elseif look == 0 then textItemSetText (kills,"Kills: "..zombieKills) -- SET THE TEXT FOR THE TEXTDISPLAY textItemSetText (rank,"Rank: "..myRank) end givePlayerMoney (killer, 25) setAccountData (player,"zombieKills",zombieKills+1) -- SET ZOMBIEKILLS +1 setElementData ( killer, "Zombie Kills", zombieKills+1) if (getAccountData (player,"zombieKills") == 20) then -- SET THE ACCOUNT & ELEMENT DATA FOR ZOMBIE KILLS setAccountData (player,"rank","[2]PFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Private First Class.") triggerClientEvent("r1", getRootElement()) elseif (getAccountData (player,"zombieKills") == 40) then setAccountData (player,"rank","[3]SPC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Specialist.") triggerClientEvent("r2", getRootElement()) elseif (getAccountData (player,"zombieKills") == 100) then setAccountData (player,"rank","[4]CPL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Corporal.") triggerClientEvent("r3", getRootElement()) elseif (getAccountData (player,"zombieKills") == 200) then setAccountData (player,"rank","[5]SGT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant.") triggerClientEvent("r4", getRootElement()) elseif (getAccountData (player,"zombieKills") == 350) then setAccountData (player,"rank","[6]SSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Staff Sergeant.") triggerClientEvent("r5", getRootElement()) elseif (getAccountData (player,"zombieKills") == 600) then setAccountData (player,"rank","[7]SFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant First Class.") triggerClientEvent("r6", getRootElement()) elseif (getAccountData (player,"zombieKills") == 900) then setAccountData (player,"rank","[8]MSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Master Sergeant.") triggerClientEvent("r7", getRootElement()) elseif (getAccountData (player,"zombieKills") == 1500) then setAccountData (player,"rank","[9]1SG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Sergeant.") triggerClientEvent("r8", getRootElement()) elseif (getAccountData (player,"zombieKills") == 1800) then setAccountData (player,"rank","[10]SGM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major.") triggerClientEvent("r9", getRootElement()) elseif (getAccountData (player,"zombieKills") == 2300) then setAccountData (player,"rank","[11]CSM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Command Sergeant Major.") triggerClientEvent("r10", getRootElement()) elseif (getAccountData (player,"zombieKills") == 3000) then setAccountData (player,"rank","[12]SMA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major of the Army.") triggerClientEvent("r11", getRootElement()) elseif (getAccountData (player,"zombieKills") == 4000) then setAccountData (player,"rank","[13]2LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Second Lieutenant.") triggerClientEvent("r12", getRootElement()) elseif (getAccountData (player,"zombieKills") == 5500) then setAccountData (player,"rank","[14]1LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Lieutenant.") triggerClientEvent("r13", getRootElement()) elseif (getAccountData (player,"zombieKills") == 7000) then setAccountData (player,"rank","[15]CPT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Captain.") triggerClientEvent("r14", getRootElement()) elseif (getAccountData (player,"zombieKills") == 9000) then setAccountData (player,"rank","[16]MAJ") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major.") triggerClientEvent("r15", getRootElement()) elseif (getAccountData (player,"zombieKills") == 11500) then setAccountData (player,"rank","[17]LTC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant Colonel.") triggerClientEvent("r16", getRootElement()) elseif (getAccountData (player,"zombieKills") == 14000) then setAccountData (player,"rank","[18]COL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Colonel.") triggerClientEvent("r17", getRootElement()) elseif (getAccountData (player,"zombieKills") == 17000) then setAccountData (player,"rank","[19]BG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Brigadier General.") triggerClientEvent("r18", getRootElement()) elseif (getAccountData (player,"zombieKills") == 21000) then setAccountData (player,"rank","[20]MG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major General.") triggerClientEvent("r19", getRootElement()) elseif (getAccountData (player,"zombieKills") == 26000) then setAccountData (player,"rank","[21]LTG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant General.") triggerClientEvent("r20", getRootElement()) elseif (getAccountData (player,"zombieKills") == 35000) then setAccountData (player,"rank","[22]GEN") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a General.") triggerClientEvent("r21", getRootElement()) elseif (getAccountData (player,"zombieKills") == 50000) then setAccountData (player,"rank","[23]GA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has reached the highest rank! He is General of the Army!") triggerClientEvent("r22", getRootElement()) end end ) Client function imagedraw() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix() for k, v in ipairs(getElementsByType("player")) do if(getElementData(v, "Admin") == true) then tx, ty, tz = getElementPosition(v) dist = math.sqrt((px - tx) ^ 2 + (py - ty) ^ 2 + (pz - tz) ^ 2) if dist < 30.0 then if isLineOfSightClear(px, py, pz, tx, ty, tz, true, false, false, true, false, false, getLocalPlayer()) then local sx, sy, sz = getPedBonePosition(v, 5) local x,y = getScreenFromWorldPosition(sx, sy, sz + 0.3) if x then dxDrawImage ( x, y, 50, 50, "rang/admin.png" ) -- DRAW A IMAGE ABOVE ADMIN`S HEAD end end end end end end addEventHandler("onClientRender",getRootElement(),imagedraw) local xp,yp = guiGetScreenSize() x = xp/2 - 100/2+ 500 y = yp/2 - 100/2 + yp/4.5 image1 = guiCreateStaticImage( x,y, 100, 100, "rang/r1.png", false ) addEvent("r1", true) function image2() guiStaticImageLoadImage( image1, "rang/r2.png" ) -- ADD EVENTS FOR NEW RANK PICTURES end addEvent("r2", true) function image3() guiStaticImageLoadImage( image1, "rang/r3.png" ) end addEvent("r3", true) function image4() guiStaticImageLoadImage( image1, "rang/r4.png" ) end addEvent("r4", true) function image5() guiStaticImageLoadImage( image1, "rang/r5.png" ) end addEvent("r5", true) function image6() guiStaticImageLoadImage( image1, "rang/r6.png" ) end addEvent("r6", true) function image7() guiStaticImageLoadImage( image1, "rang/r7.png" ) end addEvent("r7", true) function image8() guiStaticImageLoadImage( image1, "rang/r8.png" ) end addEvent("r8", true) function image9() guiStaticImageLoadImage( image1, "rang/r9.png" ) end addEvent("r9", true) function image10() guiStaticImageLoadImage( image1, "rang/r10.png" ) end addEvent("r10", true) function image11() guiStaticImageLoadImage( image1, "rang/r11.png" ) end addEvent("r11", true) function image12() guiStaticImageLoadImage( image1, "rang/r12.png" ) end addEvent("r12", true) function image13() guiStaticImageLoadImage( image1, "rang/r13.png" ) end addEvent("r13", true) function image14() guiStaticImageLoadImage( image1, "rang/r14.png" ) end addEvent("r14", true) function image15() guiStaticImageLoadImage( image1, "rang/r15.png" ) end addEvent("r15", true) function image16() guiStaticImageLoadImage( image1, "rang/r16.png" ) end addEvent("r16", true) function image17() guiStaticImageLoadImage( image1, "rang/r17.png" ) end addEvent("r17", true) function image18() guiStaticImageLoadImage( image1, "rang/r18.png" ) end addEvent("r18", true) function image19() guiStaticImageLoadImage( image1, "rang/r19.png" ) end addEvent("r19", true) function image20() guiStaticImageLoadImage( image1, "rang/r20.png" ) end addEvent("r20", true) function image21() guiStaticImageLoadImage( image1, "rang/r21.png" ) end addEvent("r21", true) function image22() guiStaticImageLoadImage( image1, "rang/r22.png" ) end addEvent("r22", true) function image23() guiStaticImageLoadImage( image1, "rang/r23.png" ) end addEventHandler( "r1", getResourceRootElement(), image2 ) -- ADD EVENT HANDLERS FOR THE NEW PICTURES addEventHandler( "r2", getResourceRootElement(), image3 ) addEventHandler( "r3", getResourceRootElement(), image4 ) addEventHandler( "r4", getResourceRootElement(), image5 ) addEventHandler( "r5", getResourceRootElement(), image6 ) addEventHandler( "r6", getResourceRootElement(), image7 ) addEventHandler( "r7", getResourceRootElement(), image8 ) addEventHandler( "r8", getResourceRootElement(), image9 ) addEventHandler( "r9", getResourceRootElement(), image10 ) addEventHandler( "r10", getResourceRootElement(), image11 ) addEventHandler( "r11", getResourceRootElement(), image12 ) addEventHandler( "r12", getResourceRootElement(), image13 ) addEventHandler( "r13", getResourceRootElement(), image14 ) addEventHandler( "r14", getResourceRootElement(), image15 ) addEventHandler( "r15", getResourceRootElement(), image16 ) addEventHandler( "r16", getResourceRootElement(), image17 ) addEventHandler( "r17", getResourceRootElement(), image18 ) addEventHandler( "r18", getResourceRootElement(), image19 ) addEventHandler( "r19", getResourceRootElement(), image20 ) addEventHandler( "r20", getResourceRootElement(), image21 ) addEventHandler( "r21", getResourceRootElement(), image22 ) addEventHandler( "r22", getResourceRootElement(), image23 ) dude, my advice to you redo or modify someone else's. Link to comment
#Paper Posted March 5, 2011 Share Posted March 5, 2011 server function scorebrett() exports.scoreboard:addScoreboardColumn("Rank") -- ON RESOURCE START SETUP exports.scoreboard:addScoreboardColumn("Zombie kills") local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do --IDK THAT FUNCS display = textCreateDisplay() textDisplayAddObserver (display,thePlayer) -- end end addEventHandler( "onResourceStart", getResourceRootElement(getThisResource()), scorebrett ) function killtherank(thePlayer) local player = getPlayerAccount ( thePlayer) local myRank = getAccountData(thePlayer,"rank") setAccountData(thePlayer,"rank","[1]PVT") getAccountData(thePlayer, "zombieKills", 0) -- SET ALL DATA TO 0 (Doesnt work ) outputChatBox ("Account deleted.", thePlayer) end addCommandHandler("killrank", killtherank) addEventHandler ("onPlayerJoin",getRootElement(), function (source) local playerac = getPlayerAccount(source) local look = nil local accountname = getAccountName(playerac) -- SET ELEMENT DATA TO IDENTIFY ADMINS if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then setElementData(source, "Admin") end end) addEvent("onZombieWasted") addEventHandler( "onZombieWasted", getRootElement(), function (killer) local player = getPlayerAccount ( killer ) local myRank = getAccountData(killer ,"rank") -- GET THE ACCOUNT local zombieKills = getAccountData(killer , "zombieKills") if (myRank == "" or myRank == nil or myRank == false) then myRank = "[1]PVT" setElementData ( killer, "Rank", "[1]PVT") -- IF RANK DOESNT EXIST, MAKE RANK 1 end if (zombieKills == "" or zombieKills == nil or zombieKills == false) then zombieKills = 0 end if look == nil then look = 0 kills = textCreateTextItem ("Kills: "..zombieKills,0.8,0.5,"medium",255,255,255,255,1.5) -- CREATE THE TEXT ITEMS rank = textCreateTextItem ("Rank: "..myRank,0.8,0.53,"medium",255,255,255,255,1.5) textDisplayAddText (display,kills) textDisplayAddText (display,rank) elseif look == 0 then textItemSetText (kills,"Kills: "..zombieKills) -- SET THE TEXT FOR THE TEXTDISPLAY textItemSetText (rank,"Rank: "..myRank) end givePlayerMoney (killer, 25) setAccountData (killer ,"zombieKills",zombieKills+1) -- SET ZOMBIEKILLS +1 setElementData ( killer, "Zombie Kills", zombieKills+1) if (getAccountData (killer ,"zombieKills") == 20) then -- SET THE ACCOUNT & ELEMENT DATA FOR ZOMBIE KILLS setAccountData (killer ,"rank","[2]PFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Private First Class.") triggerClientEvent("r1", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 40) then setAccountData (killer ,"rank","[3]SPC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Specialist.") triggerClientEvent("r2", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 100) then setAccountData (killer ,"rank","[4]CPL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Corporal.") triggerClientEvent("r3", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 200) then setAccountData (killer ,"rank","[5]SGT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant.") triggerClientEvent("r4", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 350) then setAccountData (killer ,"rank","[6]SSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Staff Sergeant.") triggerClientEvent("r5", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 600) then setAccountData (killer ,"rank","[7]SFC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant First Class.") triggerClientEvent("r6", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 900) then setAccountData (killer ,"rank","[8]MSG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Master Sergeant.") triggerClientEvent("r7", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 1500) then setAccountData (killer ,"rank","[9]1SG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Sergeant.") triggerClientEvent("r8", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 1800) then setAccountData (killer ,"rank","[10]SGM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major.") triggerClientEvent("r9", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 2300) then setAccountData (killer ,"rank","[11]CSM") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Command Sergeant Major.") triggerClientEvent("r10", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 3000) then setAccountData (killer ,"rank","[12]SMA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Sergeant Major of the Army.") triggerClientEvent("r11", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 4000) then setAccountData (killer ,"rank","[13]2LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Second Lieutenant.") triggerClientEvent("r12", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 5500) then setAccountData (killer ,"rank","[14]1LT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a First Lieutenant.") triggerClientEvent("r13", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 7000) then setAccountData (killer ,"rank","[15]CPT") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Captain.") triggerClientEvent("r14", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 9000) then setAccountData (killer ,"rank","[16]MAJ") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major.") triggerClientEvent("r15", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 11500) then setAccountData (killer ,"rank","[17]LTC") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant Colonel.") triggerClientEvent("r16", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 14000) then setAccountData (killer ,"rank","[18]COL") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Colonel.") triggerClientEvent("r17", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 17000) then setAccountData (killer ,"rank","[19]BG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Brigadier General.") triggerClientEvent("r18", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 21000) then setAccountData (killer ,"rank","[20]MG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Major General.") triggerClientEvent("r19", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 26000) then setAccountData (killer ,"rank","[21]LTG") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a Lieutenant General.") triggerClientEvent("r20", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 35000) then setAccountData (killer ,"rank","[22]GEN") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has been promoted. He is now a General.") triggerClientEvent("r21", getRootElement()) elseif (getAccountData (killer ,"zombieKills") == 50000) then setAccountData (killer ,"rank","[23]GA") setElementData ( killer, "Rank", myrank ) outputChatBox (getPlayerName(killer).." has reached the highest rank! He is General of the Army!") triggerClientEvent("r22", getRootElement()) end end ) Client function imagedraw() local px, py, pz, tx, ty, tz, dist px, py, pz = getCameraMatrix() for k, v in ipairs(getElementsByType("player")) do if(getElementData(v, "Admin") == true) then tx, ty, tz = getElementPosition(v) dist = math.sqrt((px - tx) ^ 2 + (py - ty) ^ 2 + (pz - tz) ^ 2) if dist < 30.0 then if isLineOfSightClear(px, py, pz, tx, ty, tz, true, false, false, true, false, false, getLocalPlayer()) then local sx, sy, sz = getPedBonePosition(v, 5) local x,y = getScreenFromWorldPosition(sx, sy, sz + 0.3) if x then dxDrawImage ( x, y, 50, 50, "rang/admin.png" ) -- DRAW A IMAGE ABOVE ADMIN`S HEAD end end end end end end addEventHandler("onClientRender",getRootElement(),imagedraw) local xp,yp = guiGetScreenSize() x = xp/2 - 100/2+ 500 y = yp/2 - 100/2 + yp/4.5 image1 = guiCreateStaticImage( x,y, 100, 100, "rang/r1.png", false ) addEvent("r1", true) function image2() guiStaticImageLoadImage( image1, "rang/r2.png" ) -- ADD EVENTS FOR NEW RANK PICTURES end addEvent("r2", true) function image3() guiStaticImageLoadImage( image1, "rang/r3.png" ) end addEvent("r3", true) function image4() guiStaticImageLoadImage( image1, "rang/r4.png" ) end addEvent("r4", true) function image5() guiStaticImageLoadImage( image1, "rang/r5.png" ) end addEvent("r5", true) function image6() guiStaticImageLoadImage( image1, "rang/r6.png" ) end addEvent("r6", true) function image7() guiStaticImageLoadImage( image1, "rang/r7.png" ) end addEvent("r7", true) function image8() guiStaticImageLoadImage( image1, "rang/r8.png" ) end addEvent("r8", true) function image9() guiStaticImageLoadImage( image1, "rang/r9.png" ) end addEvent("r9", true) function image10() guiStaticImageLoadImage( image1, "rang/r10.png" ) end addEvent("r10", true) function image11() guiStaticImageLoadImage( image1, "rang/r11.png" ) end addEvent("r11", true) function image12() guiStaticImageLoadImage( image1, "rang/r12.png" ) end addEvent("r12", true) function image13() guiStaticImageLoadImage( image1, "rang/r13.png" ) end addEvent("r13", true) function image14() guiStaticImageLoadImage( image1, "rang/r14.png" ) end addEvent("r14", true) function image15() guiStaticImageLoadImage( image1, "rang/r15.png" ) end addEvent("r15", true) function image16() guiStaticImageLoadImage( image1, "rang/r16.png" ) end addEvent("r16", true) function image17() guiStaticImageLoadImage( image1, "rang/r17.png" ) end addEvent("r17", true) function image18() guiStaticImageLoadImage( image1, "rang/r18.png" ) end addEvent("r18", true) function image19() guiStaticImageLoadImage( image1, "rang/r19.png" ) end addEvent("r19", true) function image20() guiStaticImageLoadImage( image1, "rang/r20.png" ) end addEvent("r20", true) function image21() guiStaticImageLoadImage( image1, "rang/r21.png" ) end addEvent("r21", true) function image22() guiStaticImageLoadImage( image1, "rang/r22.png" ) end addEvent("r22", true) function image23() guiStaticImageLoadImage( image1, "rang/r23.png" ) end addEventHandler( "r1", getResourceRootElement(getThisResource()), image2 ) -- ADD EVENT HANDLERS FOR THE NEW PICTURES addEventHandler( "r2", getResourceRootElement(getThisResource()), image3 ) addEventHandler( "r3", getResourceRootElement(getThisResource()), image4 ) addEventHandler( "r4", getResourceRootElement(getThisResource()), image5 ) addEventHandler( "r5", getResourceRootElement(getThisResource()), image6 ) addEventHandler( "r6", getResourceRootElement(getThisResource()), image7 ) addEventHandler( "r7", getResourceRootElement(getThisResource()), image8 ) addEventHandler( "r8", getResourceRootElement(getThisResource()), image9 ) addEventHandler( "r9", getResourceRootElement(getThisResource()), image10 ) addEventHandler( "r10", getResourceRootElement(getThisResource()), image11 ) addEventHandler( "r11", getResourceRootElement(getThisResource()), image12 ) addEventHandler( "r12", getResourceRootElement(getThisResource()), image13 ) addEventHandler( "r13", getResourceRootElement(getThisResource()), image14 ) addEventHandler( "r14", getResourceRootElement(getThisResource()), image15 ) addEventHandler( "r15", getResourceRootElement(getThisResource()), image16 ) addEventHandler( "r16", getResourceRootElement(getThisResource()), image17 ) addEventHandler( "r17", getResourceRootElement(getThisResource()), image18 ) addEventHandler( "r18", getResourceRootElement(getThisResource()), image19 ) addEventHandler( "r19", getResourceRootElement(getThisResource()), image20 ) addEventHandler( "r20", getResourceRootElement(getThisResource()), image21 ) addEventHandler( "r21", getResourceRootElement(getThisResource()), image22 ) addEventHandler( "r22", getResourceRootElement(getThisResource()), image23 ) Try if it works Link to comment
12p Posted March 5, 2011 Share Posted March 5, 2011 Suggestion to take out about 100 code lines at client: Instead of using, "addEvent" and "addEventHandler" 23 times, and make a function per event... You could use "for": for i = 1, 23 do addEvent ( "r"..tostring ( i ), true ) addEventHandler ( "r"..tostring ( i ), getResourceRootElement ( ), function ( ) guiStaticImageLoadImage( image1, "rang/r"..tostring( i )..".png" ) end ) I think that would work. Link to comment
Castillo Posted March 5, 2011 Share Posted March 5, 2011 lol, yeah i was wondering why he has done all those events. Link to comment
Einheit-101 Posted March 5, 2011 Author Share Posted March 5, 2011 Wow you all really know what youre doing.... lol, yeah i was wondering why he has done all those events. Answer: Because I have no experience 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