SA-MP Forums Archive
help about a coins system please help me - 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: help about a coins system please help me (/showthread.php?tid=245104)



help about a coins system please help me - jejemonerz123 - 30.03.2011

help about this i still cant compile this Sh*t

C:\Documents and Settings\user\Desktop\CallOfDutytheriseoftheheros\ pawno\include\Dini.inc(46) : error 017: undefined symbol "MAX_STRING"
C:\Documents and Settings\user\Desktop\CallOfDutytheriseoftheheros\ pawno\include\Dini.inc(46) : error 009: invalid array size (negative, zero or out of bounds)
C:\Documents and Settings\user\Desktop\CallOfDutytheriseoftheheros\ pawno\include\Dini.inc(46) : error 036: empty statement
C:\Documents and Settings\user\Desktop\CallOfDutytheriseoftheheros\ pawno\include\Dini.inc(46) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

#include <a_samp>
#include <Dini>
#include <zcmd>
#include <sscanf2>

#define PlayerFile "Coins/%s.ini"

#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,
pInfo[MAX_PLAYERS][PLAYER_MAIN];

public OnPlayerConnect(playerid) { SavePlayerCoins(playerid); return 1; }

public OnPlayerDisconnect(playerid, reason) { LoadPlayerCoins(playerid); return 1; }

CMD:givecoins(playerid,params[])
{
if(sscanf2(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(N ame)); 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;
}


CMD:coins(playerid,params[])
{
if(sscanf2(params, "u", giveplayerid)) SendClientMessage(playerid, Orange, "USAGE : /coins [playerid]");
else if(giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, Red, "ERROR : That player is not connected!");
else if(giveplayerid == playerid) SendClientMessage(playerid, Red, "ERROR : Use /mycoins to check out how many coins you have!");
else
{
new string[156], str[MAX_PLAYER_NAME]; GetPlayerName(giveplayerid, str, sizeof(str));
format(string, sizeof(string), "SERVER : Player %s has %d!", str, pInfo[giveplayerid][Coins]);
SendClientMessage(playerid, Limegreen, string);
}
return 1;
}

CMD: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;
}

CMDetcoins(playerid,params[])
{
if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, Red, "ERROR : Only admins can use that command!");
if(sscanf2(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(N ame)); 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;
}

CMD:hacked(playerid,params[])
{
pInfo[playerid][Coins] -= 100;
SendClientMessage(playerid,0xFFFFFFAA,"HaHaHa !!! You have been hacked ! 100 Coins are taken from you .");
return 1;
}

CMD:hacker(playerid,params[])
{
pInfo[playerid][Coins] += 100;
SendClientMessage(playerid,0xFFFFFFAA,"You Hacked somebody ! You get 100 Coins .");
return 1;
}

stock SavePlayerCoins(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");
}

stock LoadPlayerCoins(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);
dini_IntSet(file,"Coins", pInfo[playerid][Coins]);
}
stock sscanf2(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 __sscanf2_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 __sscanf2_FOREACH__
#undef foreach
#undef __sscanf2_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;
}


Re: help about a coins system please help me - -Rebel Son- - 30.03.2011

Remove the include. And put this at the bottom of your script.

PHP Code:
stock sscanf(string[], format[], {Float,_}:...)
{
    
#if defined isnull
        
if (isnull(string))
    
#else
        
if (string[0] == || (string[0] == && 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(paramPos0num 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(paramPos0num);
            }
            case 
'c':
            {
                
setarg(paramPos0string[stringPos++]);
            }
            case 
'f':
            {
                new 
changestr[16], changepos 0strpos 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(stringformat[formatPos], falsestringPos)) == -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(paramPos0id);
                }
                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 (
Playerplayerid)
                    {
                        
GetPlayerName(playeridnamesizeof (name));
                        if (!
strcmp(namestring[stringPos], trueid))
                        {
                            
setarg(paramPos0playerid);
                            
num true;
                            break;
                        }
                    }
                    if (!
num)
                    {
                        
setarg(paramPos0INVALID_PLAYER_ID);
                    }
                    
string[end] = ch;
                    
#if defined __SSCANF_FOREACH__
                        #undef foreach
                        #undef __SSCANF_FOREACH__
                    #endif
                
}
                
stringPos end;
            }
            case 
's''z':
            {
                new
                    
0,
                    
ch;
                if (
format[formatPos])
                {
                    while ((
ch string[stringPos++]) && ch != delim)
                    {
                        
setarg(paramPosi++, ch);
                    }
                    if (!
i)
                    {
                        return -
1;
                    }
                }
                else
                {
                    while ((
ch string[stringPos++]))
                    {
                        
setarg(paramPosi++, ch);
                    }
                }
                
stringPos--;
                
setarg(paramPosi'\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;




Re: help about a coins system please help me - PinkFloydLover - 30.03.2011

Or, you could just change :
pawn Code:
#include < sscanf >
#include < a_samp >
#include < Dini >
#include < zcmd >
to this:
pawn Code:
#include < a_samp >
#include < sscanf >
#include < Dini >
#include < zcmd >



Re: help about a coins system please help me - jejemonerz123 - 30.03.2011

thanks


Re: help about a coins system please help me - jejemonerz123 - 30.03.2011

but still cant compile it Come on


Re: help about a coins system please help me - jejemonerz123 - 30.03.2011

new problem again i now used sscanf2 but still cant compile tsk tsk


Re: help about a coins system please help me - jejemonerz123 - 30.03.2011

if you will fix this i will add your name in /credits in my server and you will be a moderator there + 200 Score


Re: help about a coins system please help me - Serbish - 30.03.2011

pawn Code:
#define MAX_STRING 128



Re: help about a coins system please help me - jejemonerz123 - 30.03.2011

Quote:
Originally Posted by Serbish
View Post
pawn Code:
#define MAX_STRING 128
where will i add it can you make a downloadlink for the fixed version of it please


Re: help about a coins system please help me - Zh3r0 - 30.03.2011

Quote:
Originally Posted by jejemonerz123
View Post
where will i add it can you make a downloadlink for the fixed version of it please
Copy, paste, destination > after <a_samp>

Also:

# Reported