Jump to content
  • 0

Coins help


xxSPEEDYxx

Question

Am fakt coins....imi merge tot cand dau copile...dar cand intru pe sv si scriu /givecoins sau /mycoins sau /setcoins imi da:Command %s doesn't exist please use /cmds

PLSSSSSSSSSSSSSSSSSSSSSS help

#include <a_samp>

#include <Dini>

#define PlayerFile                  "Coins System/%s.ini"

#pragma unused strtok

#define coinsD 187

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

#define Red 0xFF0000FF

#define Grey 0xAFAFAFAA

#define Green 0x33AA33AA

#define Yellow 0xFFFF00AA

#define White 0xFFFFFFAA

#define Blue 0x0000BBAA

#define Lightblue 0x33CCFFAA

#define Orange 0xFF9900AA

#define Lime 0x10F441AA

#define Magenta 0xFF00FFFFT

#define Navy 0x000080AA

#define Aqua 0xF0F8FFAA

#define Crimson 0xDC143CAA

#define Black 0x000000AA

#define Brown 0XA52A2AAA

#define Gold 0xB8860BAA

#define Limegreen 0x32CD32AA

enum PLAYER_MAIN

{

  Coins

}

new giveplayerid, amount;

new pInfo[MAX_PLAYERS][PLAYER_MAIN];

public OnPlayerConnect(playerid)

{

new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);

if(!dini_Exists(file)) {

    dini_Create(file);

dini_IntSet(file,"Coins", pInfo[playerid][Coins]);

}

pInfo[playerid][Coins] = dini_Int(file,"Coins");

return 1;

}

public OnPlayerDisconnect(playerid, reason)

{

new file[100],Name[MAX_PLAYER_NAME],Ip[16]; GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);

dini_IntSet(file,"Coins", pInfo[playerid][Coins]);

return 1;

}

public OnPlayerCommandText(playerid, cmdtext[])

{

    dcmd(givecoins, 11, cmdtext);

    dcmd(setcoins, 10, cmdtext);

    dcmd(mycoins, 9, cmdtext);

dcmd(coinshelp, 10, cmdtext);

    return 0;

}

dcmd_coinshelp(playerid, params[])

{

#pragma unused params

if(IsPlayerAdmin(playerid) == 1) return ShowPlayerDialog(playerid, coinsD+1, DIALOG_STYLE_MSGBOX, "Coins Help", "/setcoins [playerid] [amount]\n/givecoins [playerid] [amount]\n/coins - Will display your total coins.", "Done", "Exit");

ShowPlayerDialog(playerid, coinsD+2, DIALOG_STYLE_MSGBOX, "Coins Help", "/givecoins [playerid] [amount]\n/coins - Will display your total coins.", "Done", "Exit");

return 1;

}

dcmd_givecoins(playerid, params[])

{

if(sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, Orange, "USAGE : /givecoins [playerid] [amount]");

else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "ERROR : That player is not connected!");

else if(giveplayerid == playerid) SendClientMessage(playerid, Red, "ERROR : You cant send yourself coins!");

else if(amount > pInfo[playerid][Coins]) SendClientMessage(playerid, Red, "ERROR : You dont have that amount of coins!");

else

{

new string[156],file[100],Name[MAX_PLAYER_NAME],Ip[16],name[MAX_PLAYER_NAME]; GetPlayerName(giveplayerid, name, sizeof(name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);

format(string, sizeof(string), "SERVER : You have succesfully sent %d coins to %s!", amount, name);

SendClientMessage(playerid, Limegreen, string);

format(string, sizeof(string), "SERVER : %s has given you %d coins!", Name, amount);

SendClientMessage(giveplayerid, Limegreen, string);

pInfo[giveplayerid][Coins] += amount;

pInfo[playerid][Coins] -= amount;

dini_IntSet(file,"Coins", pInfo[giveplayerid][Coins]);

dini_IntSet(file,"Coins", pInfo[playerid][Coins]);

}

return 1;

}

dcmd_mycoins(playerid, params[])

{

#pragma unused params

new string[126];

format(string, sizeof(string), "SERVER : You have %d coins!", pInfo[playerid][Coins]);

SendClientMessage(playerid, Limegreen, string);

return 1;

}

dcmd_setcoins(playerid, params[])

{

if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, Red, "ERROR : Only admins can use that command!");

if(sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, Orange, "USAGE : /setcoins [playerid] [amount]");

else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "ERROR : That player is not connected!");

else

{

new string[156],file[100],Name[MAX_PLAYER_NAME],Ip[16],name[MAX_PLAYER_NAME]; GetPlayerName(giveplayerid, name, sizeof(name));GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);

format(string, sizeof(string), "SERVER : You have succesfully setted %s coins to %d!", name, amount);

SendClientMessage(playerid, Limegreen, string);

format(string, sizeof(string), "SERVER : Admin %s has setted your coins to %d!", Name, amount);

SendClientMessage(giveplayerid, Limegreen, string);

pInfo[giveplayerid][Coins] = amount;

dini_IntSet(file,"Coins", pInfo[giveplayerid][Coins]);

}

return 1;

}

stock sscanf(string[], format[], {Float,_}:...)

{

#if defined isnull

if (isnull(string))

#else

if (string[0] == 0 || (string[0] == 1 && string[1] == 0))

#endif

{

return format[0];

}

#pragma tabsize 4

new

formatPos = 0,

stringPos = 0,

paramPos = 2,

paramCount = numargs(),

delim = ' ';

while (string[stringPos] && string[stringPos] <= ' ')

{

stringPos++;

}

while (paramPos < paramCount && string[stringPos])

{

switch (format[formatPos++])

{

case '\0':

{

return 0;

}

case 'i', 'd':

{

new

neg = 1,

num = 0,

ch = string[stringPos];

if (ch == '-')

{

neg = -1;

ch = string[++stringPos];

}

do

{

stringPos++;

if ('0' <= ch <= '9')

{

num = (num * 10) + (ch - '0');

}

else

{

return -1;

}

}

while ((ch = string[stringPos]) > ' ' && ch != delim);

setarg(paramPos, 0, num * neg);

}

case 'h', 'x':

{

new

num = 0,

ch = string[stringPos];

do

{

stringPos++;

switch (ch)

{

case 'x', 'X':

{

num = 0;

continue;

}

case '0' .. '9':

{

num = (num << 4) | (ch - '0');

}

case 'a' .. 'f':

{

num = (num << 4) | (ch - ('a' - 10));

}

case 'A' .. 'F':

{

num = (num << 4) | (ch - ('A' - 10));

}

default:

{

return -1;

}

}

}

while ((ch = string[stringPos]) > ' ' && ch != delim);

setarg(paramPos, 0, num);

}

case 'c':

{

setarg(paramPos, 0, string[stringPos++]);

}

case 'f':

{

new changestr[16], changepos = 0, strpos = stringPos;

while(changepos < 16 && string[strpos] && string[strpos] != delim)

{

changestr[changepos++] = string[strpos++];

    }

changestr[changepos] = '\0';

setarg(paramPos,0,_:floatstr(changestr));

}

case 'p':

{

delim = format[formatPos++];

continue;

}

case '\'':

{

new

end = formatPos - 1,

ch;

while ((ch = format[++end]) && ch != '\'') {}

if (!ch)

{

return -1;

}

format[end] = '\0';

if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)

{

if (format[end + 1])

{

return -1;

}

return 0;

}

format[end] = '\'';

stringPos = ch + (end - formatPos);

formatPos = end + 1;

}

case 'u':

{

new

end = stringPos - 1,

id = 0,

bool:num = true,

ch;

while ((ch = string[++end]) && ch != delim)

{

if (num)

{

if ('0' <= ch <= '9')

{

id = (id * 10) + (ch - '0');

}

else

{

num = false;

}

}

}

if (num && IsPlayerConnected(id))

{

setarg(paramPos, 0, id);

}

else

{

#if !defined foreach

#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))

#define __SSCANF_FOREACH__

#endif

string[end] = '\0';

num = false;

new

name[MAX_PLAYER_NAME];

id = end - stringPos;

foreach (Player, playerid)

{

GetPlayerName(playerid, name, sizeof (name));

if (!strcmp(name, string[stringPos], true, id))

{

setarg(paramPos, 0, playerid);

num = true;

break;

}

}

if (!num)

{

setarg(paramPos, 0, INVALID_PLAYER_ID);

}

string[end] = ch;

#if defined __SSCANF_FOREACH__

#undef foreach

#undef __SSCANF_FOREACH__

#endif

}

stringPos = end;

}

case 's', 'z':

{

new

i = 0,

ch;

if (format[formatPos])

{

while ((ch = string[stringPos++]) && ch != delim)

{

setarg(paramPos, i++, ch);

}

if (!i)

{

return -1;

}

}

else

{

while ((ch = string[stringPos++]))

{

setarg(paramPos, i++, ch);

}

}

stringPos--;

setarg(paramPos, i, '\0');

}

default:

{

continue;

}

}

while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')

{

stringPos++;

}

while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))

{

stringPos++;

}

paramPos++;

}

do

{

if ((delim = format[formatPos++]) > ' ')

{

if (delim == '\'')

{

while ((delim = format[formatPos++]) && delim != '\'') {}

}

else if (delim != 'z')

{

return delim;

}

}

}

while (delim > ' ');

return 0;

}

Fara reclama in semnatura!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.