SA-MP Forums Archive
counting - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: counting (/showthread.php?tid=77544)



counting - Sal_Kings - 12.05.2009

how do i make something when i type a command like /count it sends me a message saying you have counted two times...

/count - You have counted 1 times
/count - You have counted 2 times

It saves when u logout and on death. How?

I want to add it to my /buygun so each time you type /buygun it says you have bought a gun one time.


Re: counting - Weirdosport - 12.05.2009

Well the count bit itself is fairly simple, but to save it requires some additional parts.

pawn Code:
new Count[MAX_PLAYERS];
new string[128];
pawn Code:
if (strcmp("/count", cmdtext, true, 6) == 0)
    {
    Count[playerid]++;
    format(string, sizeof(string), "You have counted %d times", Count[playerid]);
    SendClientMessage(playerid, 0xFF00FFFF, string);
    return 1;
    }
The above script will only work for a single session and each time you restart the script it'll be back to 0. Now you have a choice of how you wish to save your variables. You can use fwrite() to create your own saving system, or use one that is already set-up like DJSon or Dini (both by Dracoblue). You could also use Dudb, but it would be a bit of a shame to create a file for every player that only contains 1 variable...





Re: counting - Sal_Kings - 12.05.2009

Thx bro