[Help] Stats system
#1

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;
}
Reply
#2

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;
}
Reply
#3

Can you do it with dcmd?
Reply
#4

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

Код:
#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;
}
Reply
#6

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
Reply
#7

Thanks Kavinsky, urs works

But it comes Kills
Death

How to make it in one line.
Reply
#8

Try:
pawn Код:
#pragma unused params
Reply
#9

I already got #pragma unused params

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

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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)