Assigning ID's to self created achievements
#1

Hi

I'm creating achievements for my GM
And I use this function to create a new one:
pawn Код:
stock AddAchievement(aid, name[56], info[126], money, gld)
{
    format(AInfo[currentachieveslot][Name], 56, "%s", name);
    format(AInfo[currentachieveslot][Info], 56, "%s", info);

    AInfo[currentachieveslot][Aid] = aid;
    AInfo[currentachieveslot][Money] = money;
    AInfo[currentachieveslot][Gold] = gld;

    return currentachieveslot, currentachieveslot ++;
}
Well now what I was trying to do is assigning id's to these achievements so that I could easly select information from an achievement.

So here's what I tried doing:

pawn Код:
billgates = AddAchievement(billgates, "Bill Gates", "Get over 1 billion $$$", 20000, 0);
    shumacher = AddAchievement(shumacher, "Shumacher", "Win 50 races", 20000, 0);
    fanatic = AddAchievement(fanatic, "Fanatic player", "Play over 12 hours", 20000, 0);
    flagchamp = AddAchievement(flagchamp, "Flag champion", "Keep the /flag for over 20 minuts", 20000, 0);
    killerbee = AddAchievement(killerbee, "Killerbee", "Kill 500 people", 20000, 0);
    serialkiller = AddAchievement(serialkiller, "Serial killer", "Kill 1000 people", 20000, 0);
However when I tried then later using those ID's like this:
pawn Код:
stock CheckForAchievements(playerid)
{
    if(PInfo[playerid][Money] == 1000000000) Achieve(playerid, billgates);
    if(PInfo[playerid][RacesWon] == 50) Achieve(playerid, shumacher);
    if(PInfo[playerid][Score] == 12*60) Achieve(playerid, fanatic);
    if(PInfo[playerid][Kills] == 500) Achieve(playerid, killerbee);
    if(PInfo[playerid][Kills] == 1000) Achieve(playerid, serialkiller);
   
    return 1;
}

stock Achieve(playerid, achieveid)
{
    SendClientMessage(playerid, -1, AInfo[achieveid][Name]);
    return 1;
}
It gives me several errors:
Код:
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : error 012: invalid function call, not a valid address
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : warning 215: expression has no effect
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : warning 215: expression has no effect
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : error 001: expected token: ";", but found ")"
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : error 029: invalid expression, assumed zero
C:\Users\Els\Documents\GTA San Andreas User Files\Server\VintageStunts3\gamemodes\TerribleStuntsYINI.pwn(5485) : fatal error 107: too many error messages on one line

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


4 Errors.
Any help is appreciated,
thanks in advance
Reply
#2

I'm not sure where the line is, however I can guess that the error is at:
pawn Код:
stock AddAchievement(aid, name[56], info[126], money, gld)
{
    format(AInfo[currentachieveslot][Name], 56, "%s", name);
    format(AInfo[currentachieveslot][Info], 56, "%s", info);

    AInfo[currentachieveslot][Aid] = aid;
    AInfo[currentachieveslot][Money] = money;
    AInfo[currentachieveslot][Gold] = gld;

    return currentachieveslot, currentachieveslot ++; // here
}
Which should be solved by:
pawn Код:
stock AddAchievement(aid, name[56], info[126], money, gld)
{
    format(AInfo[currentachieveslot][Name], 56, "%s", name);
    format(AInfo[currentachieveslot][Info], 56, "%s", info);

    AInfo[currentachieveslot][Aid] = aid;
    AInfo[currentachieveslot][Money] = money;
    AInfo[currentachieveslot][Gold] = gld;

    currentachieveslot ++;
    return (currentachieveslot - 1); // here
}
Reply
#3

I'm sorry I forgot to tell you where it is, but no that is not the problem I'm very sure that what I did in that stock wasn't wrong (I got the same errors btw)

The error line is here:
pawn Код:
if(PInfo[playerid][Money] == 1000000000) Achieve(playerid, billgates);
It's where I try to use the ID's which means they aren't properly assigned...

EDIT: Nvm got it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)