SA-MP Forums Archive
player stats - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: player stats (/showthread.php?tid=437268)



player stats - OpticKiller - 14.05.2013

i need some help am trying to find out how to make player stats etc but there is not a single tut on how to make it can soemone please help me with it.


Re: player stats - [L]azy[H]aze - 14.05.2013

do you mean like a saving system ? where it saves all stats ?


Re: player stats - jordy.kiesebrink - 14.05.2013

I dont know how good you are in scipting? but globally their are two ways to store such data. and i say globally becouse i know their are others mirror methods for this. however you can use a database with mysql or use dini to save it into a .txt file, if you dont want to make this yourself .. why dont you run an adminscript for your server theire are anove scripts to download and they store playerstats mostly. if they dont its a verry poor admin script


Re: player stats - OpticKiller - 14.05.2013

Quote:
Originally Posted by Kefir
Посмотреть сообщение
do you mean like a saving system ? where it saves all stats ?
nah just like player stats

i will show you what i mean


Код:
Something like this but obvis i cant use this as its not on my script.
public ShowStats(playerid,targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
	{
		new cash =  GetPlayerMoney(targetid);
		new atext[20];
		if(PlayerInfo[targetid][pSex] == 1)
		{ atext = "Male"; }
		else if(PlayerInfo[targetid][pSex] == 2)
		{ atext = "Female"; }
  		new otext[20];
		if(PlayerInfo[targetid][pPlace] == 1)
		{ otext = "Europe"; }
		else if(PlayerInfo[targetid][pPlace] == 2)
		{ otext = "America"; }
		new drank[20];
		if(PlayerInfo[targetid][pVip] == 1)
		{ drank = "Gold Donator"; }
		else if(PlayerInfo[targetid][pVip] == 2)
		{ drank = "Silver Donator"; }
		else { drank = "None"; }
		new age = PlayerInfo[targetid][pAge];
		new warns = PlayerInfo[targetid][pWarns];
		new level = PlayerInfo[targetid][pLevel];
		new exp = PlayerInfo[targetid][pExp];
		new nxtlevel = PlayerInfo[targetid][pLevel]+1;
		new expamount = nxtlevel*levelexp;
		new costlevel = nxtlevel*levelcost;
		new name[MAX_PLAYER_NAME];
		new pnumber = PlayerInfo[targetid][pNumber];
		GetPlayerName(targetid, name, sizeof(name));
		new Float:px,Float:py,Float:pz;
		GetPlayerPos(targetid, px, py, pz);
		new coordsstring[128];
		SendClientMessage(playerid, COLOR_GREEN,"_____________________________________________________________________________________________");
		format(coordsstring, sizeof(coordsstring),"*** %s ***",name);
		SendClientMessage(playerid, COLOR_YELLOW,coordsstring);
		format(coordsstring, sizeof(coordsstring), "Level:[%d] Sex:[%s] Age:[%d] Origin:[%s] Cash:[$%d] Phone:[%d] ", level,atext,age,otext, cash, pnumber);
		SendClientMessage(playerid, COLOR_WHITE,coordsstring);
		format(coordsstring, sizeof(coordsstring), "DonateRank:[%s] Warns:[%d/5]", drank, warns);
		SendClientMessage(playerid, COLOR_LIGHTBLUE,coordsstring);
		format(coordsstring, sizeof(coordsstring), "NextLevel:[$%d] Respect:[%d/%d]",costlevel,exp,expamount);
		SendClientMessage(playerid, COLOR_LIGHTBLUE,coordsstring);
		SendClientMessage(playerid, COLOR_GREEN,"____________________________________________________________________________________________");
	}
}



Re: player stats - jordy.kiesebrink - 14.05.2013

So if I am not wrong you created or downloaded an adminscript where you already have saved player information in like score kills deaths and now you would like to make a dialog or something where a player can see this information from himself ingame. can you specify what your wishes are please?


Re: player stats - OpticKiller - 15.05.2013

Well this is my Pinfo but i just want a simple public stats etc level cash and such others like owned vehicles. if its better on a dialog then whatever but also i am kinda new at scripting a GM from line 1 lol


Код:
enum pInfo
{
	pPass,
	pCash,
	pAdmin,
 	pWarns,
	pKills,
	pDeaths,
 	TutKick,
    AdminLevel,
    pMuted,
   	pMuteTime,
    pLevel,
    pLocked,
    pTester,
   	pModel,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
EDIT: dont look at the space cos it ant like that


Re: player stats - RvGamers - 15.05.2013

You're going to want to post this in the scripting help section of the forums. It's the proper section and more people are browsing it anyways - you'll get help a lot quicker.

http://forum.sa-mp.com/forumdisplay.php?f=12

Also, if you have Pawn code you can post it in the [ PAWN ][ /PAWN ] tags (without the spacing of course).


Re: player stats - jordy.kiesebrink - 15.05.2013

Oke I will give you a example with zcmd and sscanf, if you don't want to use this you should compile this to strcmp yourself. assuming that you saved these statics somewhere and can call it with your enum pInfo I would say this must work for you:

pawn Код:
#define DIALOG_USERSTATS 1234
//^ this is the dialog id for the userstatics, place this on top of your script under de includes

COMMAND:stats(playerid, params[]) {//defining the command that must be entered to control this dialog.
    new targetid;//this is needed to check the targetid's stats in the sscanf switch.
    if(!sscanf(params, "U(-1)", targetid)) {//this is giving a optinal paramater (the targetid), when the command is called without a targetid it will show your stats.
        //this is the playerid dialog
        new string[2000];//now we are making a new string to show up in the dialog
        strcat(string, "KIlls: %d\n", PlayerInfo[playerid][pKills]);//this is formating your string
        strcat(string, "Deaths: %d\n", PlayerInfo[playerid][pDeaths]);
        strcat(string, "Money: %d\n", PlayerInfo[playerid][pCash]);//copy this with whatever you want to show in the dialog    
        ShowPlayerDialog(playerid, DIALOG_USERSTATS, DIALOG_STYLE_MSGBOX, "Your statics", string, "OK", "");
     } else {
        //this is the targetid dialog
        new string[2000];//now we are making a new string to show up in the dialog
        strcat(string, "KIlls: %d\n", PlayerInfo[targetid][pKills]);//this is formating your string
        strcat(string, "Deaths: %d\n", PlayerInfo[targetid][pDeaths]);
        strcat(string, "Money: %d\n", PlayerInfo[targetid][pCash]);//copy this with whatever you want to show in the dialog    
        ShowPlayerDialog(playerid, DIALOG_USERSTATS, DIALOG_STYLE_MSGBOX, "Target statics", string, "OK", "");
    }
    return 1;
}
I hope this helped you I didnt tested it! If this is not working please contact me or find our what is wrong

Kind regarts, Jordy


Re: player stats - OpticKiller - 15.05.2013

Nope the command works but the dialog werid dont show me the money etc. never mind anyways i try and make one


Re: player stats - jordy.kiesebrink - 17.05.2013

Quote:
Originally Posted by OpticKiller
Посмотреть сообщение
Nope the command works but the dialog werid dont show me the money etc. never mind anyways i try and make one
You managed to create it? Or are you stuck in this. Usually this should get the information from your enum, when you configurated that in the right way