SA-MP Forums Archive
[Help] Stats system - 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] Stats system (/showthread.php?tid=291145)



[Help] Stats system - alainchaccour - 18.10.2011

Ok I have this stat system, it saves Kills, Death, Cash, Score.
And I want it to show those with a cmd /stats. How to make that?

Код:
#define FILTERSCRIPT

#include <a_samp>
#include <Dini>
#include <Dutils>
#include <Dudb>

#define savefolder "/save/%s.ini"

#pragma unused ret_memcpy

new Killz[MAX_PLAYERS];
new Deathz[MAX_PLAYERS];

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[128];
	new file[128];
	GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), savefolder,pname);
    if(!dini_Exists(file)) {
        dini_Create(file);
        dini_IntSet(file, "Score", 0);
        dini_IntSet(file, "Money", 0);
        dini_IntSet(file, "Kills", Killz[playerid]);
        dini_IntSet(file, "Deaths", Deathz[playerid]);
        SetPlayerScore(playerid, dini_Int(file, "Score"));
        SetPlayerMoney(playerid, dini_Int(file, "Money"));

    }
    else
	{
        SetPlayerScore(playerid, dini_Int(file, "Score"));
        SetPlayerMoney(playerid, dini_Int(file, "Money"));
        SetPlayerSkin(playerid, dini_Int(file, "Skin"));
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new pname[128];
	new file[128];
	GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), savefolder,pname);
    if(!dini_Exists(file)) {
    }
    else {
        dini_IntSet(file, "Score", GetPlayerScore(playerid));
        dini_IntSet(file, "Money", GetPlayerMoney(playerid));
        dini_IntSet(file, "Kills", Killz[playerid]);
        dini_IntSet(file, "Deaths", Deathz[playerid]);
    }
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	Killz[killerid] ++;
	Deathz[playerid] ++;
	return 1;
}



Re: [Help] Stats system - =WoR=Varth - 18.10.2011

pawn Код:
CMD:stats(playerid,params[])
{
   new string[32];
   format(string,sizeof(string),"Kill: %d",Killz[playerid]);
   SendClientMessage(playerid,-1,string);
   format(string,sizeof(string),"Death: %d",Deathz[playerid]);
   SendClientMessage(playerid,-1,string);
   return 1;
}



Re: [Help] Stats system - alainchaccour - 18.10.2011

Can you do it with dcmd?


Re: [Help] Stats system - =WoR=Varth - 18.10.2011

https://sampforum.blast.hk/showthread.php?tid=243191


Re: [Help] Stats system - Kavinsky - 18.10.2011

Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
        dcmd(stats, 5, cmdtext);
}

dcmd_stats(playerid,params[])
{
     #pragma unused params
      new string[32];
      format(string,sizeof(string),"Kill: %d",Killz[playerid]);
      SendClientMessage(playerid,-1,string);
      format(string,sizeof(string),"Death: %d",Deathz[playerid]);
      SendClientMessage(playerid,-1,string);
      return 1;
}



Re: [Help] Stats system - alainchaccour - 18.10.2011

I added this:

Код:
#include <sscanf2>

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(stats, 3, cmdtext);
    return 1;
}

dcmd_stats(playerid, params[])
{
    new string[32];
    format(string,sizeof(string),"Kill: %d",Killz[playerid]);
    SendClientMessage(playerid,-1,string);
    format(string,sizeof(string),"Death: %d",Deathz[playerid]);
    SendClientMessage(playerid,-1,string);
    return 1;
}
I get this warning:
Код:
C:\Users\Chaccour\Desktop\CS\filterscripts\savings.pwn(80) : warning 203: symbol is never used: "params"
And I tried the cmd, it didnt show anythingg


Re: [Help] Stats system - alainchaccour - 18.10.2011

Thanks Kavinsky, urs works

But it comes Kills
Death

How to make it in one line.


Re: [Help] Stats system - Stigg - 18.10.2011

Try:
pawn Код:
#pragma unused params



Re: [Help] Stats system - alainchaccour - 18.10.2011

I already got #pragma unused params

I want the stats to show in one line, no 2 lines


Re: [Help] Stats system - Stigg - 18.10.2011

Quote:
Originally Posted by alainchaccour
Посмотреть сообщение
I already got #pragma unused params

I want the stats to show in one line, no 2 lines
Try:
pawn Код:
dcmd_stats(playerid, params[])
{
    #pragma unused params
    new string[32];
    format(string,sizeof(string),"Kills: %d Deaths: %d",Killz[playerid],Deathz[playerid]);
    SendClientMessage(playerid,-1,string);
    return 1;
}