AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help Showing a HUD and player list. (https://forums.alliedmods.net/showthread.php?t=55800)

Styles 05-29-2007 21:48

Help Showing a HUD and player list.
 
PHP Code:

public updateHud(id)
{
    
//if(isOfficer(id) == 0) return PLUGIN_HANDLED
    
new jaillist[2048] = "Players in jail:^n" 
    
new player_id[32], players_numplayer_name[32], jailName[64], flagtemp[128]
    
get_players(player_idplayers_num)
    for (new 
0players_numi++)
    {
        
flag getFlag(player_id[i]) 
        
get_user_name(player_id[i], player_name31)
        if(
flag 0)
        {
            
jailName jailPlace(flag)
            
format(temp,127,"%s -  %s^n",player_namejailName
            
add(jaillist,sizeof(jaillist),temp
        }
    }
    if(
strfind(jaillist,"-") == -1) {
        
add(jaillist,2047,"-  None")
    } 
    
set_hudmessage(025500.570.1206.012.0)
    
show_hudmessage(idjaillist)

    return 
PLUGIN_CONTINUE


What im attempting to do is show a player list like so.

Eathier:
Players in jail:
- none

or

Players in jail:
Peter - CELL NAME
John - CELL NAME
Bob - CELL NAME

Deviance 05-30-2007 00:01

Re: Help Showing a HUD and player list.
 
Code:
public updateHud(id) {     //if(isOfficer(id) == 0) return PLUGIN_HANDLED     new jaillist[2048], len         len = format(jaillist, 2047, "Players in jail:^n")         new player_id[32], players_num, player_name[32], jailName[64], flag         get_players(player_id, players_num)         for (new i = 0; i < players_num; i++)     {         flag = getFlag(player_id[i])         get_user_name(player_id[i], player_name, 31)             if(flag > 0)         {             jailName = jailPlace(flag)             len += format(jaillist[len], 2047-len,"%s -  %s^n", player_name, jailName)         }     }         if(strfind(jaillist,"-") == -1) {         len += format(jaillist[len], 2047-len, "-  None")     }         set_hudmessage(0, 255, 0, 0.57, 0.12, 0, 6.0, 12.0)     show_hudmessage(id, jaillist)     return PLUGIN_CONTINUE }

Styles 05-30-2007 03:05

Re: Help Showing a HUD and player list.
 
I now have

PHP Code:

public updateHud(id)
{
    
//if(isOfficer(id) == 0) return PLUGIN_HANDLED
    
new jaillist[2048], len
    set_hudmessage
(025500.570.12,0,0.0,99.9,0.0,0.0,3)
    
len format(jaillist2047"Players in jail:^n")
    
    new 
player_id[32], players_numplayer_name[32], jailName[64], flag
    get_players
(player_idplayers_num)
    
    for (new 
0players_numi++)
    {
        new 
temp player_id[i]
        
flag getFlag(temp
        
get_user_name(tempplayer_name31)
    
//flag = getFlag(i)
    //get_user_name(1, player_name, sizeof(player_name))
    
client_print(tempprint_chat"%s is Flag Num "flag)
        if(
flag != 0)
        {
            
jailName jailPlace(tempflag)
            
len += format(jaillist[len], 2047-len,"%s -  %s^n"player_namejailName
        }
    }
    
    if(
strfind(jaillist,"-") == -1) {
        
len += format(jaillist[len], 2047-len"-  None")
    } 
    
    
    
show_hudmessage(idjaillist)

    return 
PLUGIN_CONTINUE


But it prints out is flag num not the name or anything. idk why.. noob fix porobally.

v3x 05-30-2007 03:48

Re: Help Showing a HUD and player list.
 
You're going to need to show more code. Like your jailPlace function, for example.

Cheap_Suit 05-30-2007 05:04

Re: Help Showing a HUD and player list.
 
Just have something like this in the jailPlace function.
PHP Code:

public jailPlace(flagstring[], len)
{
 switch(
flag)
 {
  case ?: 
formatex(stringlen"jailname")
 }


PHP Code:

new jailname[64]
jailPlace(flagjailname63


Styles 05-30-2007 17:35

Re: Help Showing a HUD and player list.
 
I know my funtcion is like

public publicJail(flagnum)
{
new string;
switch(flagnum)
{
case 0: string = "hi";
default: string = "error";
}
return string;
}

What Im saying is its having a problem geting the users NAME ect.. information that way i can't print out a name or a current flag num cuz it can't get them right.

Cheap_Suit 05-30-2007 19:05

Re: Help Showing a HUD and player list.
 
AFAIK, you cant format strings like that.

Lee 05-30-2007 19:11

Re: Help Showing a HUD and player list.
 
I don't think you can use strings as a case in a switch block either.

Styles 05-30-2007 23:36

Re: Help Showing a HUD and player list.
 
heres jailPlace.

Also, it doesn't even show the users name.

Code:
public jailPlace(id, flagNumber) {     new string[64]     switch(flagNumber)     {         case 0: string = "Minor Offences Cell"         case 1: string = "Robbery Cell"         case 2: string = "Major Offences Cell"         case 3: string = "Heavy Assault Cell"         case 4: string = "Firing Squad"         case 6: string = "Admin Cell 1"         case 7: string = "Admin Cell 2"         case 8: string = "Catacombes"         default: string = "Error"     }     return string }

Styles 06-03-2007 01:48

Re: Help Showing a HUD and player list.
 
Anyone, I could really use this.


All times are GMT -4. The time now is 10:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.