SA-MP Forums Archive
Help , easy peasy problem, i give rep! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help , easy peasy problem, i give rep! (/showthread.php?tid=544966)



Help , easy peasy problem, i give rep! - buburuzu19 - 05.11.2014

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;
}



Re: Help , easy peasy problem, i give rep! - VishvaJeet - 05.11.2014

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;
}



Re: Help , easy peasy problem, i give rep! - buburuzu19 - 05.11.2014

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.


Re: Help , easy peasy problem, i give rep! - VishvaJeet - 05.11.2014

Код:
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;
}



Re: Help , easy peasy problem, i give rep! - buburuzu19 - 05.11.2014

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


Re: Help , easy peasy problem, i give rep! - M4D - 05.11.2014

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



Re: Help , easy peasy problem, i give rep! - buburuzu19 - 05.11.2014

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.


Re: Help , easy peasy problem, i give rep! - M4D - 05.11.2014

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 !


Re: Help , easy peasy problem, i give rep! - buburuzu19 - 05.11.2014

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?


Re: Help , easy peasy problem, i give rep! - M4D - 05.11.2014

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