SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/08/2011, 06:38 PM   #1
Tanush123
High-roller
 
Tanush123's Avatar
 
Join Date: Aug 2011
Posts: 1,022
Reputation: 65
Default weird problem

when i use getstats [id], it shows another player stats
pawn Code:
CMD:getstats(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
    GetPlayerName(ID,pname,sizeof(pname));
    format(str, sizeof(str), "Name: %s\n\nAdmin Level: %d\n\nVip Level: %d\n\nHours: %d\n\nMinutes: %d\n\nBank Balance: %d",pname,PlayerData[ID][AdminLevel],PlayerData[ID][vip],PlayerData[ID][HoursPlayed],PlayerData[ID][MinutesPlayed],PlayerData[ID][Bank]);
    ShowPlayerDialog(playerid,10001,DIALOG_STYLE_MSGBOX, "Stats",str,"Close","");
    return 1;
}
Tanush123 is offline   Reply With Quote
Old 24/08/2011, 06:40 PM   #2
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: weird problem

pawn Code:
CMD:getstats(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
    GetPlayerName(playerid,pname,sizeof(pname));
    format(str, sizeof(str), "Name: %s\n\nAdmin Level: %d\n\nVip Level: %d\n\nHours: %d\n\nMinutes: %d\n\nBank Balance: %d",pname,PlayerData[playerid][AdminLevel],PlayerData[playerid][vip],PlayerData[playerid][HoursPlayed],PlayerData[playerid][MinutesPlayed],PlayerData[playerid][Bank]);
    ShowPlayerDialog(playerid,10001,DIALOG_STYLE_MSGBOX, "Stats",str,"Close","");
    return 1;
}
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 24/08/2011, 06:42 PM   #3
grand.Theft.Otto
High-roller
 
grand.Theft.Otto's Avatar
 
Join Date: Sep 2010
Location: Canada
Posts: 1,059
Reputation: 65
Default Re: weird problem

If you have sscanf, use this:

pawn Code:
CMD:getstats(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
   
    new ID, pname[24];

    if(sscanf(params,"d",id)) return SendClientMessage(playerid,color,"USAGE: /getstats [playerid]");

    GetPlayerName(ID,pname,24);

    format(str, sizeof(str), "Name: %s\n\nAdmin Level: %d\n\nVip Level: %d\n\nHours: %d\n\nMinutes: %d\n\nBank Balance: %d",pname,PlayerData[ID][AdminLevel],PlayerData[ID][vip],PlayerData[ID][HoursPlayed],PlayerData[ID][MinutesPlayed],PlayerData[ID][Bank]);
    ShowPlayerDialog(playerid,10001,DIALOG_STYLE_MSGBOX, "Stats",str,"Close","");
    return 1;
}

If not, use this:

pawn Code:
CMD:getstats(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
   
    new ID, pname[24];

    id = strval(params);

    GetPlayerName(ID,pname,24);

    format(str, sizeof(str), "Name: %s\n\nAdmin Level: %d\n\nVip Level: %d\n\nHours: %d\n\nMinutes: %d\n\nBank Balance: %d",pname,PlayerData[ID][AdminLevel],PlayerData[ID][vip],PlayerData[ID][HoursPlayed],PlayerData[ID][MinutesPlayed],PlayerData[ID][Bank]);
    ShowPlayerDialog(playerid,10001,DIALOG_STYLE_MSGBOX, "Stats",str,"Close","");
    return 1;
}

If that doesn't work, try this:

pawn Code:
CMD:getstats(playerid, params[])
{
    if(PlayerData[playerid][AdminLevel] < 1) return 0;
   
    new ID, pname[24], idx;

    id = strval(params, idx);

    GetPlayerName(ID,pname,24);

    format(str, sizeof(str), "Name: %s\n\nAdmin Level: %d\n\nVip Level: %d\n\nHours: %d\n\nMinutes: %d\n\nBank Balance: %d",pname,PlayerData[ID][AdminLevel],PlayerData[ID][vip],PlayerData[ID][HoursPlayed],PlayerData[ID][MinutesPlayed],PlayerData[ID][Bank]);
    ShowPlayerDialog(playerid,10001,DIALOG_STYLE_MSGBOX, "Stats",str,"Close","");
    return 1;
}


EDIT: nevermind, I thought you wanted to get that stats of others, not for yourself.. but if you want to do it for others, you can use my code above.
__________________


grand.Theft.Otto is offline   Reply With Quote
Old 24/08/2011, 06:45 PM   #4
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: weird problem

Oh I guess I miss understood him.
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 24/08/2011, 07:12 PM   #5
Tanush123
High-roller
 
Tanush123's Avatar
 
Join Date: Aug 2011
Posts: 1,022
Reputation: 65
Default Re: weird problem

ohh i forgot that lol, thank you
Tanush123 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VERY VERY VERY weird problem Master_Gangster Help Archive 14 22/04/2011 04:29 AM
Weird problem Scriptissue Help Archive 12 05/10/2010 04:42 PM
weird problem mige Help Archive 3 04/06/2010 06:46 PM
Weird problem DevilRP Help Archive 10 20/05/2010 12:25 AM


All times are GMT. The time now is 12:14 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.