SA-MP Forums Archive
Making a stats 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: Making a stats command.. (/showthread.php?tid=377919)



Making a stats command.. - _Khaled_ - 15.09.2012

Hello, I use Y_INI
and I made a textdraw for player stats but don't know how to show it on it..
pawn Код:
enum pInfo
{
    //pPass, Ignore the stuff in green.
    //pCash,
    pScore,
    //pAdminLevel,
    //pWantedLevel,
    //pArmy
    pArrests,
    pRobberies,
    pKills,
    pDeaths,
    //pJail,
    //pBanned
}
new PlayerInfo[MAX_PLAYERS][pInfo];

//Textdraw..

    //Stats.
    STextdraw0 = TextDrawCreate(21.000000, 111.000000, "Player Stats:");
    TextDrawBackgroundColor(STextdraw0, 255);
    TextDrawFont(STextdraw0, 1);
    TextDrawLetterSize(STextdraw0, 0.500000, 1.000000);
    TextDrawColor(STextdraw0, 16711935);
    TextDrawSetOutline(STextdraw0, 0);
    TextDrawSetProportional(STextdraw0, 1);
    TextDrawSetShadow(STextdraw0, 1);
    TextDrawUseBox(STextdraw0, 1);
    TextDrawBoxColor(STextdraw0, 75);
    TextDrawTextSize(STextdraw0, 130.000000, 0.000000);

    STextdraw1 = TextDrawCreate(21.000000, 124.000000, "Score: ");
    TextDrawBackgroundColor(STextdraw1, 255);
    TextDrawFont(STextdraw1, 1);
    TextDrawLetterSize(STextdraw1, 0.320000, 1.000000);
    TextDrawColor(STextdraw1, -1);
    TextDrawSetOutline(STextdraw1, 0);
    TextDrawSetProportional(STextdraw1, 1);
    TextDrawSetShadow(STextdraw1, 1);
    TextDrawUseBox(STextdraw1, 1);
    TextDrawBoxColor(STextdraw1, 75);
    TextDrawTextSize(STextdraw1, 130.000000, 0.000000);

    STextdraw2 = TextDrawCreate(21.000000, 165.000000, "Kills: ");
    TextDrawBackgroundColor(STextdraw2, 255);
    TextDrawFont(STextdraw2, 1);
    TextDrawLetterSize(STextdraw2, 0.350000, 1.000000);
    TextDrawColor(STextdraw2, -1);
    TextDrawSetOutline(STextdraw2, 0);
    TextDrawSetProportional(STextdraw2, 1);
    TextDrawSetShadow(STextdraw2, 1);
    TextDrawUseBox(STextdraw2, 1);
    TextDrawBoxColor(STextdraw2, 75);
    TextDrawTextSize(STextdraw2, 130.000000, 0.000000);

    STextdraw3 = TextDrawCreate(21.000000, 178.000000, "Deaths: ");
    TextDrawBackgroundColor(STextdraw3, 255);
    TextDrawFont(STextdraw3, 1);
    TextDrawLetterSize(STextdraw3, 0.350000, 1.000000);
    TextDrawColor(STextdraw3, -1);
    TextDrawSetOutline(STextdraw3, 0);
    TextDrawSetProportional(STextdraw3, 1);
    TextDrawSetShadow(STextdraw3, 1);
    TextDrawUseBox(STextdraw3, 1);
    TextDrawBoxColor(STextdraw3, 75);
    TextDrawTextSize(STextdraw3, 130.000000, 0.000000);

    STextdraw4 = TextDrawCreate(21.000000, 151.000000, "Robberies: ");
    TextDrawBackgroundColor(STextdraw4, 255);
    TextDrawFont(STextdraw4, 1);
    TextDrawLetterSize(STextdraw4, 0.330000, 1.000000);
    TextDrawColor(STextdraw4, -1);
    TextDrawSetOutline(STextdraw4, 0);
    TextDrawSetProportional(STextdraw4, 1);
    TextDrawSetShadow(STextdraw4, 1);
    TextDrawUseBox(STextdraw4, 1);
    TextDrawBoxColor(STextdraw4, 75);
    TextDrawTextSize(STextdraw4, 130.000000, 0.000000);

    STextdraw5 = TextDrawCreate(21.000000, 137.000000, "Arrests: ");
    TextDrawBackgroundColor(STextdraw5, 255);
    TextDrawFont(STextdraw5, 1);
    TextDrawLetterSize(STextdraw5, 0.320000, 1.000000);
    TextDrawColor(STextdraw5, -1);
    TextDrawSetOutline(STextdraw5, 0);
    TextDrawSetProportional(STextdraw5, 1);
    TextDrawSetShadow(STextdraw5, 1);
    TextDrawUseBox(STextdraw5, 1);
    TextDrawBoxColor(STextdraw5, 75);
    TextDrawTextSize(STextdraw5, 130.000000, 0.000000);
Tried everything but didn't work out,
someone?


Re: Making a stats command.. - HighFlyer - 15.09.2012

Код:
command(stats, playerid, params[])
{
	new string[128];
	
	format(string, sizeof(string), "Player Stats: "); // depends what you want here, nick name?
	// Look at the message below, if you want a nick name, in the speech marks, set %u to find the nick name, and after the speech marks, set the enum and fields you want to get the data from.
	TextDrawShowForPlayer(playerid, STextdraw0);
	format(string, sizeof(string), "Score: %s", pInfo[playerid][pScore]); // looks for player's score...
	TextDrawShowForPlayer(playerid, STextdraw1); // this shows the textdraw using the string above
	format(string, sizeof(string), "Kills: %s", pInfo[playerid][pKills]);
	TextDrawShowForPlayer(playerid, STextdraw2);
	format(string, sizeof(string), "Deaths: %s", pInfo[playerid][pScore]);
	TextDrawShowForPlayer(playerid, STextdraw3);
	format(string, sizeof(string), "Robberies: %s", pInfo[playerid][pRobberies]);
	TextDrawShowForPlayer(playerid, STextdraw4);
	format(string, sizeof(string), "Arrests: %s", pInfo[playerid][pArrests]);
	TextDrawShowForPlayer(playerid, STextdraw5);
	
	return 1;
}
Untested :P

For this, you need to include ZCMD in your script:
https://sampforum.blast.hk/showthread.php?tid=91354


Re: Making a stats command.. - _Khaled_ - 16.09.2012

False


Re: Making a stats command.. - _Khaled_ - 17.09.2012

bump


Re: Making a stats command.. - clarencecuzz - 17.09.2012

Quote:
Originally Posted by HighFlyer
Посмотреть сообщение
Код:
command(stats, playerid, params[])
{
	new string[128];
	
	format(string, sizeof(string), "Player Stats: "); // depends what you want here, nick name?
	// Look at the message below, if you want a nick name, in the speech marks, set %u to find the nick name, and after the speech marks, set the enum and fields you want to get the data from.
	TextDrawShowForPlayer(playerid, STextdraw0);
	format(string, sizeof(string), "Score: %s", pInfo[playerid][pScore]); // looks for player's score...
	TextDrawShowForPlayer(playerid, STextdraw1); // this shows the textdraw using the string above
	format(string, sizeof(string), "Kills: %s", pInfo[playerid][pKills]);
	TextDrawShowForPlayer(playerid, STextdraw2);
	format(string, sizeof(string), "Deaths: %s", pInfo[playerid][pScore]);
	TextDrawShowForPlayer(playerid, STextdraw3);
	format(string, sizeof(string), "Robberies: %s", pInfo[playerid][pRobberies]);
	TextDrawShowForPlayer(playerid, STextdraw4);
	format(string, sizeof(string), "Arrests: %s", pInfo[playerid][pArrests]);
	TextDrawShowForPlayer(playerid, STextdraw5);
	
	return 1;
}
Untested :P

For this, you need to include ZCMD in your script:
https://sampforum.blast.hk/showthread.php?tid=91354
Okay, and what is the point of formatting the string if you're not using it?
This won't change the textdraws...

pawn Код:
CMD:stats(playerid, params[])
{
    new string[50];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Player Stats: %s", name);
    TextDrawShowForPlayer(playerid, STextdraw0);
    TextDrawSetString(STextdraw0, string);
    format(string, sizeof(string), "Score: %d", pInfo[playerid][pScore]);
    TextDrawShowForPlayer(playerid, STextdraw1);
    TextDrawSetString(STextdraw1, string);
    format(string, sizeof(string), "Kills: %d", pInfo[playerid][pKills]);
    TextDrawShowForPlayer(playerid, STextdraw2);
    TextDrawSetString(STextdraw2, string);
    format(string, sizeof(string), "Deaths: %d", pInfo[playerid][pDeaths]);
    TextDrawShowForPlayer(playerid, STextdraw3);
    TextDrawSetString(STextdraw3, string);
    format(string, sizeof(string), "Robberies: %d", pInfo[playerid][pRobberies]);
    TextDrawShowForPlayer(playerid, STextdraw4);
    TextDrawSetString(STextdraw4, string);
    format(string, sizeof(string), "Arrests: %d", pInfo[playerid][pArrests]);
    TextDrawShowForPlayer(playerid, STextdraw5);
    TextDrawSetString(STextdraw5, string);
    return 1;
}
NOTE: Untested


Re: Making a stats command.. - Camacorn - 17.09.2012

None of those will work. For starters, those text draws are global, so if you update them, it will change for everybody, not just the player that does /stats. Change the ids to TextdrawName[i] and place them under a loop. And in the stats command, use TextdrawName[playerid] for the text draw names.

If you need more information, message me on MSN.


Re: Making a stats command.. - clarencecuzz - 17.09.2012

Oh true. I don't have much experience with textdraws, but when looking over the code it does make more sense. :S