[Hilfe]Scoreboard

  • Ultimate
  • [Hilfe]Scoreboard

    Guten Tag,

    Ich bin gerade dabei mein neues Scoreboard einzurichten. Aber irgendwie komme ich gerade nicht weiter. Ich habe in meinem Scoreboard 4 Spalten wo drinne stehen soll "Name" dann "Spielzeit" dann "Fraktion" und hinten kommt dann "Information" hin das sich automatisch nach Rang ändert. Bis dahin ist auch alles gut. Aber irgendwie weiß ich nicht wo ich einstellen kann wie das aussehen soll. Wenn ein Spieler drauf ist. Momentan sieht es so bei mir aus: prntscr.com/dtduhv
    Das mit Spielzeit Spielzeit und Telefonnr und Fraktion sowie Ping braucht ihr nicht zu beachten. Da bin ich gerade dran. Aber wie schaffe ich das das der Name die Spielzeit die Fraktion und die Information richtig unter der Linie angezeigt werden? PS: Ich benutze das Ultimate Reallife Script.

    Ich hoffe mir kann jemand helfen.
  • Quellcode

    1. local playerListLabels = {}
    2. local playerListFactionMembersLabel = {}
    3. local playersOnline = {}
    4. local playersOnlineData = {}
    5. local curPlayerListPosition = 1
    6. local playerCount = 0
    7. local playerListWidth = 650
    8. local playerListHeight = 360
    9. local maxPlayersInCurList = 17
    10. local maxPlayers = 250
    11. local playersToScrollPerButton = 10
    12. function recieveServerSlotCount ( max )
    13. maxPlayers = max
    14. end
    15. addEvent ( "recieveServerSlotCount", true )
    16. addEventHandler ( "recieveServerSlotCount", getRootElement(), recieveServerSlotCount )
    17. triggerServerEvent ( "getServerSlotCount", lp )
    18. local radioUpState, radioDownState, weaponUpState, weaponDownState = true
    19. function fillPlayerListOnStart ()
    20. local players = getElementsByType ( "player" )
    21. for key, index in pairs ( players ) do
    22. playerCount = playerCount + 1
    23. playersOnlineData[index] = playerCount
    24. playersOnline[playerCount] = index
    25. end
    26. end
    27. fillPlayerListOnStart ()
    28. function clientPlayerListDisconnect ()
    29. local i = playersOnlineData[source]
    30. playersOnline[i] = nil
    31. playerCount = playerCount - 1
    32. end
    33. addEventHandler ( "onClientPlayerQuit", getRootElement(), clientPlayerListDisconnect )
    34. function clientPlayerListConnect ()
    35. local i
    36. for k = 1, maxPlayers do
    37. if not playersOnline[k] then
    38. i = k
    39. break
    40. end
    41. end
    42. playerCount = playerCount + 1
    43. playersOnlineData[source] = i
    44. playersOnline[i] = source
    45. end
    46. addEventHandler ( "onClientPlayerJoin", getRootElement(), clientPlayerListConnect )
    47. function showPlayerList ()
    48. if gImage["playerList"] then
    49. guiSetVisible ( gImage["playerList"], true )
    50. else
    51. local label, img
    52. --gImage["playerList"] = guiCreateStaticImage(screenwidth/2-playerListWidth/2,screenheight/2-playerListHeight/2,playerListWidth,playerListHeight,"images/colors/c_black.jpg",false)
    53. gImage["playerList"] = guiCreateStaticImage(screenwidth/2-playerListWidth/2,screenheight/2-playerListHeight/2,playerListWidth,playerListHeight,"images/scoreboard.png",false)
    54. guiSetAlpha(gImage["playerList"],0.9)
    55. label = guiCreateLabel(74,73,51,23,"Name",false,gImage["playerList"])
    56. guiSetAlpha(label,1)
    57. guiLabelSetColor(label,255,255,255)
    58. guiLabelSetVerticalAlign(label,"top")
    59. guiLabelSetHorizontalAlign(label,"left",false)
    60. guiSetFont(label,"default-bold-small")
    61. --img = guiCreateStaticImage(8,20,453,5,"images/colors/c_green.jpg",false,gImage["playerList"])
    62. --guiSetAlpha(img,0.7)
    63. label = guiCreateLabel(166,39,88,23,"Spielzeit",false,gImage["playerList"])
    64. guiSetAlpha(label,1)
    65. guiLabelSetColor(label,255,255,255)
    66. guiLabelSetVerticalAlign(label,"top")
    67. guiLabelSetHorizontalAlign(label,"left",false)
    68. guiSetFont(label,"default-bold-small")
    69. label = guiCreateLabel(290,39,52,20,"Spielzeit",false,gImage["playerList"])
    70. guiSetAlpha(label,1)
    71. guiLabelSetColor(label,255,255,255)
    72. guiLabelSetVerticalAlign(label,"top")
    73. guiLabelSetHorizontalAlign(label,"left",false)
    74. guiSetFont(label,"default-bold-small")
    75. --img = guiCreateStaticImage(151,28,3,268,"images/colors/c_green.jpg",false,gImage["playerList"])
    76. --guiSetAlpha(img,0.7)
    77. --img = guiCreateStaticImage(265,28,3,268,"images/colors/c_green.jpg",false,gImage["playerList"])
    78. --guiSetAlpha(img,0.7)
    79. label = guiCreateLabel(360,39,62,16,"Telefonnr.",false,gImage["playerList"])
    80. guiSetAlpha(label,1)
    81. guiLabelSetColor(label,255,255,255)
    82. guiLabelSetVerticalAlign(label,"top")
    83. guiLabelSetHorizontalAlign(label,"left",false)
    84. guiSetFont(label,"default-bold-small")
    85. --img = guiCreateStaticImage(333,28,3,268,"images/colors/c_green.jpg",false,gImage["playerList"])
    86. --guiSetAlpha(img,0.7)
    87. --img = guiCreateStaticImage(413,28,3,268,"images/colors/c_green.jpg",false,gImage["playerList"])
    88. --guiSetAlpha(img,0.7)
    89. label = guiCreateLabel(443,39,65,15,"Fraktion",false,gImage["playerList"])
    90. guiSetAlpha(label,1)
    91. guiLabelSetColor(label,255,255,255)
    92. guiLabelSetVerticalAlign(label,"top")
    93. guiLabelSetHorizontalAlign(label,"left",false)
    94. guiSetFont(label,"default-bold-small")
    95. label = guiCreateLabel(546,39,57,15,"Ping",false,gImage["playerList"])
    96. guiSetAlpha(label,1)
    97. guiLabelSetColor(label,255,255,255)
    98. guiLabelSetVerticalAlign(label,"top")
    99. guiLabelSetHorizontalAlign(label,"left",false)
    100. guiSetFont(label,"default-bold-small")
    101. --gImage["playerListBarBG"] = guiCreateStaticImage(472,0,12,playerListHeight,"images/colors/c_white.jpg",false,gImage["playerList"])
    102. --guiSetAlpha(gImage["playerListBarBG"],0.7)
    103. --gImage["playerListBarPull"] = guiCreateStaticImage(0,17,12,33,"images/colors/c_black.jpg",false,gImage["playerListBarBG"])
    104. --guiSetAlpha(gImage["playerListBarPull"],1)
    105. gLabel["playerListPlayers"] = guiCreateLabel(45,330,100,18,"0/"..maxPlayers.." Spieler",false,gImage["playerList"])
    106. guiSetAlpha(gLabel["playerListPlayers"],1)
    107. guiLabelSetColor(gLabel["playerListPlayers"],255,255,255)
    108. guiLabelSetVerticalAlign(gLabel["playerListPlayers"],"top")
    109. guiLabelSetHorizontalAlign(gLabel["playerListPlayers"],"left",false)
    110. guiSetFont(gLabel["playerListPlayers"],"default-bold-small")
    111. for i, index in pairs ( factionColors ) do
    112. if i > 0 then
    113. local r, g, b = factionColors[i][1], factionColors[i][2], factionColors[i][3]
    114. playerListFactionMembersLabel[i] = guiCreateLabel(175+175+(i)*20,330,20,18,"",false,gImage["playerList"])
    115. guiSetAlpha(playerListFactionMembersLabel[i],1)
    116. guiLabelSetColor(playerListFactionMembersLabel[i],r,g,b)
    117. guiLabelSetVerticalAlign(playerListFactionMembersLabel[i],"top")
    118. guiLabelSetHorizontalAlign(playerListFactionMembersLabel[i],"left",false)
    119. guiSetFont(playerListFactionMembersLabel[i],"default-bold-small")
    120. end
    121. end
    122. for i = 1, maxPlayersInCurList do
    123. playerListLabels[i] = {}
    124. playerListLabels[i][1] = guiCreateLabel(40,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    125. playerListLabels[i][2] = guiCreateLabel(166,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    126. playerListLabels[i][3] = guiCreateLabel(290,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    127. playerListLabels[i][4] = guiCreateLabel(360,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    128. playerListLabels[i][5] = guiCreateLabel(443,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    129. playerListLabels[i][6] = guiCreateLabel(546,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    130. for k = 1, 6 do
    131. guiSetAlpha(playerListLabels[i][k],1)
    132. guiLabelSetColor(playerListLabels[i][k],255,255,255)
    133. guiLabelSetVerticalAlign(playerListLabels[i][k],"top")
    134. guiLabelSetHorizontalAlign(playerListLabels[i][k],"left",false)
    135. guiSetFont(playerListLabels[i][k],"default-bold-small")
    136. end
    137. guiLabelSetColor ( playerListLabels[i][2], 200, 200, 0 )
    138. end
    139. end
    140. updatePlayerList ()
    141. end
    142. function updateFactionPlayerCount ()
    143. factionCounter = {}
    144. local players = getElementsByType ( "player" )
    145. for key, index in pairs ( players ) do
    146. local i = getElementData ( index, "fraktion" )
    147. if i then
    148. if not factionCounter[i] then
    149. factionCounter[i] = {}
    150. end
    151. factionCounter[i][index] = true
    152. end
    153. end
    154. for i, index in pairs ( factionColors ) do
    155. if playerListFactionMembersLabel[i] then
    156. local length = tableLength ( factionCounter[i] )
    157. if length > 0 then
    158. guiSetText ( playerListFactionMembersLabel[i], length )
    159. else
    160. guiSetText ( playerListFactionMembersLabel[i], "" )
    161. end
    162. end
    163. end
    164. end
    165. function tableLength ( table )
    166. local i = 0
    167. if table then
    168. for _, _ in pairs ( table ) do
    169. i = i + 1
    170. end
    171. end
    172. return i
    173. end
    174. function updatePlayerList ()
    175. if guiGetVisible ( gImage["playerList"] ) then
    176. updateFactionPlayerCount ()
    177. guiSetText ( gLabel["playerListPlayers"], playerCount.."/"..maxPlayers.." Spieler" )
    178. reFillPlayerList ()
    179. playerListUpdateTimer = setTimer ( updatePlayerList, 1000, 1 )
    180. end
    181. end
    182. function reAdjustPlayerListScollBar ()
    183. --[[pxPerPlayer = playerListHeight / ( playerCount )
    184. barSize = maxPlayersInCurList / playerCount * playerListHeight
    185. if barSize > playerListHeight then
    186. ]]
    187. pxPerPlayer = 310 / ( playerCount )
    188. barSize = maxPlayersInCurList / playerCount * 310
    189. if barSize > 310 then
    190. barSize = 1
    191. barYPos = 0
    192. else
    193. barYPos = ( curPlayerListPosition - 1 ) * ( pxPerPlayer )
    194. end
    195. --guiSetSize ( gImage["playerListBarPull"], 17, barSize, false )
    196. --guiSetPosition ( gImage["playerListBarPull"], 0, barYPos, false )
    197. end
    198. function reFillPlayerList ()
    199. for key, index in pairs ( playerListLabels ) do
    200. for i = 1, 6 do
    201. guiSetText ( playerListLabels[key][i], "" )
    202. end
    203. end
    204. local i = 0
    205. local k = 0
    206. local name, rang, playingtime, ping, r, g, b
    207. for z = -2, factioncount do
    208. for key, index in pairs ( playersOnline ) do
    209. if ( z == -2 and not getElementData ( index, "loggedin" ) ) or ( z == -1 and getElementData ( index, "loggedin" ) == 0 ) or getElementData ( index, "fraktion" ) == z then
    210. i = i + 1
    211. if k > maxPlayersInCurList then
    212. break
    213. end
    214. if i >= curPlayerListPosition then
    215. k = k + 1
    216. name = getPlayerName ( index )
    217. rang = getElementData ( index, "socialState" )
    218. fraktion = getElementData ( index, "fraktion" )
    219. ping = tonumber ( getPlayerPing ( index ) )
    220. if not rang then
    221. rang = "Verbinden..."
    222. nr = ""
    223. playingtime = ""
    224. r, g, b = 175, 175, 175
    225. else
    226. nr = getElementData ( index, "telenr" )
    227. local faction = getElementData ( index, "fraktion" )
    228. r, g, b = factionColors[faction][1], factionColors[faction][2], factionColors[faction][3]
    229. playingtime = getElementData ( index, "playingtime" )
    230. playingtime = math.floor ( playingtime / 60 )..":"..( playingtime - math.floor ( playingtime / 60 ) * 60 )
    231. end
    232. if not fraktion then
    233. fraktion = "-"
    234. else
    235. fraktion = fraktionsNamen[fraktion] or "Zivilist"
    236. end
    237. if playerListLabels[k] and playerListLabels[k][1] and isElement(playerListLabels[k][1]) and name then
    238. guiSetText ( playerListLabels[k][1], name )
    239. guiSetText ( playerListLabels[k][2], rang )
    240. guiSetText ( playerListLabels[k][3], playingtime )
    241. guiSetText ( playerListLabels[k][4], nr )
    242. guiSetText ( playerListLabels[k][5], fraktion )
    243. guiSetText ( playerListLabels[k][6], ping )
    244. pr, pg, pb = getPingColor ( ping )
    245. local admlvl = getElementData ( index, "adminlvl" )
    246. if admlvl and admlvl >= 1 then
    247. guiLabelSetColor ( playerListLabels[k][2], 0, 200, 0 )
    248. else
    249. guiLabelSetColor ( playerListLabels[k][2], 200, 200, 0 )
    250. end
    251. guiLabelSetColor ( playerListLabels[k][1], r, g, b )
    252. guiLabelSetColor ( playerListLabels[k][5], r, g, b )
    253. guiLabelSetColor ( playerListLabels[k][6], pr, pg, pb )
    254. end
    255. end
    256. end
    257. end
    258. end
    259. end
    260. function getPingColor ( ping )
    261. if ping <= 50 then
    262. return 0, 200, 0
    263. elseif ping <= 150 then
    264. return 200, 200, 0
    265. else
    266. return 200, 0, 0
    267. end
    268. end
    269. function playerListScrollDown ()
    270. if curPlayerListPosition < playerCount - maxPlayersInCurList + playersToScrollPerButton then
    271. curPlayerListPosition = curPlayerListPosition + playersToScrollPerButton
    272. else
    273. curPlayerListPosition = playerCount
    274. end
    275. reFillPlayerList ()
    276. end
    277. function playerListScrollUp ()
    278. if curPlayerListPosition > playersToScrollPerButton then
    279. curPlayerListPosition = curPlayerListPosition - playersToScrollPerButton
    280. else
    281. curPlayerListPosition = 1
    282. end
    283. reFillPlayerList ()
    284. end
    285. function playerListKeyPressed ( key, state )
    286. if state == "down" then
    287. radioUpState = isControlEnabled ( "radio_next" )
    288. radioDownState = isControlEnabled ( "radio_previous" )
    289. weaponUpState = isControlEnabled ( "next_weapon" )
    290. weaponDownState = isControlEnabled ( "previous_weapon" )
    291. toggleControl ( "radio_next", false )
    292. toggleControl ( "radio_previous", false )
    293. toggleControl ( "next_weapon", false )
    294. toggleControl ( "previous_weapon", false )
    295. toggleControl ( "radio_user_track_skip", false )
    296. showCursor(true)
    297. unbindKey ( "radio_next", "down", customRadioChannelSwitchUp )
    298. unbindKey ( "radio_previous", "down", customRadioChannelSwitchDown )
    299. if isTimer ( playerListUpdateTimer ) then
    300. killTimer ( playerListUpdateTimer )
    301. end
    302. scollBarAdjustTimer = setTimer ( reAdjustPlayerListScollBar, 50, 0 )
    303. bindKey ( "mouse_wheel_up", "down", playerListScrollUp )
    304. bindKey ( "mouse_wheel_down", "down", playerListScrollDown )
    305. showPlayerList ()
    306. else
    307. if isControlEnabled ( "next_weapon" ) then
    308. toggleControl ( "radio_next", true )
    309. toggleControl ( "radio_previous", true )
    310. toggleControl ( "next_weapon", true )
    311. toggleControl ( "previous_weapon", true )
    312. showCursor(false)
    313. else
    314. if radioUpState ~= nil then
    315. toggleControl ( "radio_next", radioUpState )
    316. else
    317. toggleControl ( "radio_next", true )
    318. end
    319. if radioDownState ~= nil then
    320. toggleControl ( "radio_previous", radioDownState )
    321. else
    322. toggleControl ( "radio_previous", true )
    323. end
    324. if weaponUpState ~= nil then
    325. toggleControl ( "next_weapon", weaponUpState )
    326. else
    327. toggleControl ( "next_weapon", true )
    328. end
    329. if weaponDownState ~= nil then
    330. toggleControl ( "previous_weapon", weaponDownState )
    331. else
    332. toggleControl ( "previous_weapon", true )
    333. end
    334. end
    335. toggleControl ( "radio_user_track_skip", true )
    336. bindKey ( "radio_next", "down", customRadioChannelSwitchUp )
    337. bindKey ( "radio_previous", "down", customRadioChannelSwitchDown )
    338. if isTimer ( scollBarAdjustTimer ) then
    339. killTimer ( scollBarAdjustTimer )
    340. end
    341. unbindKey ( "mouse_wheel_up", "down", playerListScrollUp )
    342. unbindKey ( "mouse_wheel_down", "down", playerListScrollDown )
    343. showCursor(false)
    344. if gImage["playerList"] then
    345. guiSetVisible ( gImage["playerList"], false )
    346. end
    347. end
    348. end
    349. bindKey ( "tab", "both", playerListKeyPressed )
    Alles anzeigen
  • Einfach dies Bearbeiten

    LUA-Quellcode

    1. for i = 1, maxPlayersInCurList do
    2. playerListLabels[i] = {}
    3. playerListLabels[i][1] = guiCreateLabel(40,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    4. playerListLabels[i][2] = guiCreateLabel(166,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    5. playerListLabels[i][3] = guiCreateLabel(290,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    6. playerListLabels[i][4] = guiCreateLabel(360,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    7. playerListLabels[i][5] = guiCreateLabel(443,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])
    8. playerListLabels[i][6] = guiCreateLabel(546,55 - 16 + 16 * i,141,16,"",false,gImage["playerList"])