Help , easy peasy problem, i give rep!
#1

Hello guys. I have a problem. I made a /checkwanted command based on dialog and i found a bug. When a player disconnects the row with his name and id and wlevel is still remaining , how to destroy the row ?
pawn Код:
CMD:checkwanted(playerid, params[])
{
    new dialog[256], string[40], name[24];
    format(dialog, sizeof(dialog), "");
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
            if(PWantedLevel>= 1)
            {
                GetPlayerName(i, name, 24);
                format(string, sizeof (string), "[W:%d][ID:%d][%s]",PWantedLeveL[i],i,GetName(i));
                format(dialog, sizeof(dialog), "%s\n%s", dialog, string);
            }
    }
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, "Wanted Players", dialog, "Ok", "");
    return 1;
}
Reply
#2

Declare variable Wanted label for per player
Код:
new PWantedLevel[MAX_PLAYERS];
Код:
CMD:checkwanted(playerid, params[])
{
    new dialog[256], string[40], name[24];
    format(dialog, sizeof(dialog), "");
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
            if(PWantedLevel[i] >= 1) // if player wanted label is more than 1
            {
                GetPlayerName(i, name, 24);
                format(string, sizeof (string), "[W:%d][ID:%d][%s]",PWantedLeveL[i],i,name);
                format(dialog, sizeof(dialog), "%s\n%s", dialog, string);
            }
    }
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, "Wanted Players", dialog, "Ok", "");
    return 1;
}
Reply
#3

The variable is already declared(My fault was that i forgotted to put [i] at PWantedLeveL ,btw if player has for e.g. wanted 6 , and he /q the row with his name and id and w6 is still remaining.
Reply
#4

Код:
CMD:checkwanted(playerid, params[])
{
    new dialog[256], string[40], name[24];
    format(dialog, sizeof(dialog), "");
    for( new i = 0; i < MAX_PLAYERS; i ++ )
    {
       if(IsPlayerConnected(i)) // use if is player connected
       {
            if(PWantedLevel[i] >= 1) // if player wanted label is more than 1
            {
                GetPlayerName(i, name, 24);
                format(string, sizeof (string), "[W:%d][ID:%d][%s]",PWantedLeveL[i],i,name);
                format(dialog, sizeof(dialog), "%s\n%s", dialog, string);
            }
       }
    }
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_LIST, "Wanted Players", dialog, "Ok", "");
    return 1;
}
Reply
#5

I don't understand what you've did . I already have this in my gm.
Reply
#6

reset wanted variable when player disconnect from the server.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
 PWantedLevel[playerid] = 0;
 return 1;
}
Reply
#7

Quote:
Originally Posted by M4D
Посмотреть сообщение
reset wanted variable when player disconnect from the server.
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
 PWantedLevel[playerid] = 0;
 return 1;
}
That means, if i do this , if player gets wanted 6 for rob , and he /q and he enter again he will have 0 wanted .
Not so good ideea.
Reply
#8

lol. you have to save players wanted !
use Y_INI, Y_Users or other save system !
if you don't reset players wanted in Discconect it will be Worse!!
for example i'm in game and i have 6 wanted level. my id is 5.
i leave the server and somone else join the server and server gives him id 5.
and now he has 6 wanted ! but he never robs any shop !
Reply
#9

Calm down buddy, i am saving the wanted levels in mysql database. Only the dialog has problems and i want to make something like this:
If player has w6 and it's appearing in /checkwanted , i want to disappear if he is offline. And if he reconnects to appear back. Understood?
Reply
#10

!!!
save players wanted and after saving set variable to 0 !!
when player join again load his wanted to variable !

or if you want use it just in dialog, simply use IsPlayerConnected(i) in your dialog loop !!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)