SA-MP Forums Archive
status command - 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: status command (/showthread.php?tid=416485)



status command - Goldino - 17.02.2013

Hey guys, how do you make a /status command. I've tried it, but I keep getting errors, and sometimes they don't even work properly. I hope you can help me!

I use zcmd.


Re: status command - greentarch - 17.02.2013

If you mean /status that will show your stats, then

Example : ( only works for himself, doesnt work like " /status 5 " )
pawn Код:
CMD:status( playerid, params[ ] )
{
    new
        str[ 128 ];
    SendClientMessage( playerid, -1, "-----------------------------------------");
    SendClientMessage( playerid, -1, "Your stats :" );
    format( str, sizeof str, "Score: {33FF33}%d", GetPlayerScore( playerid ) );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof str, "Money: {33FF33}$%d", GetPlayerMoney( playerid ) );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof str, "Ping: {33FF33}%d", GetPlayerPing( playerid ) );
    SendClientMessage( playerid, -1, str );
    SendClientMessage( playerid, -1, "-----------------------------------------");
    return 1;
}
in dialogs
pawn Код:
CMD:status( playerid, params[ ] )
{
    new
        a_large_string[ 512 ];
    format( a_large_string, sizeof ( a_large_string ),
    "{FFFFFF}Score : {33FF33}%d \n\
    {FFFFFF}Money : {33FF33}$%d \n\
    {FFFFFF}Ping : {33FF33}%d"
, GetPlayerScore( playerid ), GetPlayerMoney( playerid ), GetPlayerPing( playerid ) );

    ShowPlayerDialog( playerid, 1337, DIALOG_STYLE_MSGBOX, "{FFFFFF}Your stats",
    a_large_string, "Okay", "" );

    return 1;
}
NOTE : Untested


Re: status command - Goldino - 17.02.2013

Doesn't work?


Re: status command - Goldino - 17.02.2013

Heres my enum,

Код:
enum PlayerInfo
{
    Pass[129], 
    Adminlevel, 
    VIPlevel, 
    Money, 
    Scores, 
    Kills, 
    Deaths,
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Please help!


Re: status command - Goldino - 17.02.2013

someone, plz help?


Re: status command - greentarch - 17.02.2013

What does not work? Can you be a little bit clearer?

pawn Код:
CMD:status( playerid, params[ ] )
{
    new
        str[ 128 ];
    SendClientMessage( playerid, -1, "---------------------------------------" );
    SendClientMessage( playerid, -1, "Your stats :" );
    format( str, sizeof ( str ), "Admin Level : {33FF33}%d", pInfo[ playerid ][ Adminlevel ] );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof ( str ), "VIP Level : {33FF33}%d", pInfo[ playerid ][ VIPlevel ] );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof ( str ), "Money : {33FF33}$%d", GetPlayerMoney( playerid ) );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof ( str ), "Score : {33FF33}%d", GetPlayerScore( playerid ) );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof ( str ), "Kills : {33FF33}%d", pInfo[ playerid ][ Kills ] );
    SendClientMessage( playerid, -1, str );
    format( str, sizeof ( str ), "Deaths : {33FF33}%d", pInfo[ playerid ][ Deaths ] );
    SendClientMessage( playerid -1, str );
    SendClientMessage( playerid, -1, "---------------------------------------" );
    return 1;
}
I have tested the code above at my server.
Type /status ingame.


Re: status command - Goldino - 17.02.2013

It works, but it says I've killed someone 1337 times, which I haven't and it says that I have never died?


Re: status command - greentarch - 17.02.2013

Sure :
pawn Код:
CMD:status( playerid, params[ ] )
{
    new
        str[ 1024 ]; // Yes, I know. This one is a big string size.

    format( str, sizeof ( str ),
    "{FFFFFF}Admin Level : {33FF33}%d \n\
    {FFFFFF}VIP Level : {33FF33}%d \n\
    {FFFFFF}Money : {33FF33}$%d \n\
    {FFFFFF}Score : {33FF33}%d \n\
    {FFFFFF}Kills : {33FF33}%d \n\
    {FFFFFF}Deaths : {33FF33}%d"
,
    pInfo[ playerid ][ Adminlevel ], pInfo[ playerid ][ VIPlevel ], GetPlayerMoney( playerid ), GetPlayerScore( playerid ), pInfo[ playerid ][ Kills ], pInfo[ playerid ][ Deaths ] );

    ShowPlayerDialog( playerid, 1337, DIALOG_STYLE_MSGBOX, "{FFFFFF}Your stats",
    str, "Okay", "" );

    return 1;
}
EDIT: Messed up the script 2 times, now fixed.

For the question above, check your OnPlayerDeath, it should be something like
pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
    pInfo[ killerid ][ Kills ] ++;
    pInfo[ playerid ][ Deaths ] ++;
    return 1;
}



Re: status command - Goldino - 17.02.2013

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Sure :
pawn Код:
CMD:status( playerid, params[ ] )
{
    new
        str[ 1024 ]; // Yes, I know. This one is a big string size.

    format( str, sizeof ( str ),
    "{FFFFFF}Admin Level : {33FF33}%d \n\
    {FFFFFF}VIP Level : {33FF33}%d \n\
    {FFFFFF}Money : {33FF33}$%d \n\
    {FFFFFF}Score : {33FF33}%d \n\
    {FFFFFF}Kills : {33FF33}%d \n\
    {FFFFFF}Deaths : {33FF33}%d"
,
    pInfo[ playerid ][ Adminlevel ], pInfo[ playerid ][ VIPlevel ], GetPlayerMoney( playerid ), GetPlayerScore( playerid ), pInfo[ playerid ][ Kills ], pInfo[ playerid ][ Deaths ] );

    ShowPlayerDialog( playerid, 1337, DIALOG_STYLE_MSGBOX, "{FFFFFF}Your stats",
    str, "Okay", "" );

    return 1;
}
EDIT: Messed up the script 2 times, now fixed.

For the question above, check your OnPlayerDeath, it should be something like
pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
    pInfo[ killerid ][ Kills ] ++;
    pInfo[ playerid ][ Deaths ] ++;
    return 1;
}
Correct, how do I fix it?


Re: status command - greentarch - 17.02.2013

Mhm, check your user's .ini data and see the "Kills" and "Deaths" there. Try to change it and test it again.