Little problem on a line.
#1

Hello everyone !

I've got a little error on a line, but I'm not able to find what it is.
Here is the line :

Line 22124 :
pawn Код:
if(pTazer[playerid] == 0)

And here come the errors :
Код:
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\myrp.pwn(22124) : error 028: invalid subscript (not an array or too many subscripts): "pTazer"
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\myrp.pwn(22124) : warning 215: expression has no effect
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\myrp.pwn(22124) : error 001: expected token: ";", but found "]"
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\myrp.pwn(22124) : error 029: invalid expression, assumed zero
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\myrp.pwn(22124) : fatal error 107: too many error messages on one line
Can you please help me guys ?
Thank you !
Reply
#2

Show us where you define pTazer.

I suspect pTazer is part of an enum, and that you have a variable called something like "PlayerInfo" that you should use instead, like so:
pawn Код:
if(PlayerInfo[playerid][pTazer] == 0)
Reply
#3

I use this, exactly : https://sampforum.blast.hk/showthread.php?tid=272548
I changed with the code you gave me, I got exactly the same errors actually
Reply
#4

can you show the lines around your code..
Reply
#5

pawn Код:
if(strcmp(subcmd, "taser", true) ==0 || strcmp(subcmd, "t", true) ==0)
            {
                // We make it again for TEAM_COPS
                if(gTeam[playerid] == FACT_COPS_LS) // For cops
                {
                    if(!OnDuty[playerid])
                        {SendClientMessage(playerid, COLOR_COPS, "{FF6600}[Police]{11BB00} Vous n'кtes pas en service."); return 1;}
                    if(PlayerInfo[playerid][pTazer] == 0) // If the player has no tazer withdrawn.
                    {
                        SafeGivePlayerWeapon(playerid, 23, 20); // Gives a SD.
                        pTazer[playerid] = 1; // Sets the var to true.
                        format(proxy_msg, sizeof(proxy_msg), "%s sort son taser de son hostler et l'arme.", playername);
                        ProxDetector(30.0, playerid, string, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
                        return 1;
                    }
                    else ifif(PlayerInfo[playerid][pTazer] == 1) // If the player has the tazer withdrawn to holster it.
                    {
                        SafeGivePlayerWeapon(playerid, 24, 100); // Gives a deagle.
                        pTazer[playerid] = 0; // Sets the var to false.
                        format(proxy_msg, sizeof(proxy_msg), "%s dйsarme son taser et le replace а son hostler.", playername);
                        ProxDetector(30.0, playerid, string, COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION,COLOR_ACTION);
                        return 1;
                    }
                }
                return 1;
            }






Oh, by the way, can you please explain me what is the "gTeam' in this topic ? I do'nt understand.
Thanks.
Reply
#6

Quote:
Originally Posted by Kethrios
Посмотреть сообщение
I use this, exactly : https://sampforum.blast.hk/showthread.php?tid=272548
I changed with the code you gave me, I got exactly the same errors actually
You didn't do what I told you to: Show us where you define pTazer.
Reply
#7

I need to #define it ?
If yes, I didn't do that. If not, you mean "new ..." ?
Reply
#8

Quote:
Originally Posted by Kethrios
Посмотреть сообщение
I need to #define it ?
If yes, I didn't do that. If not, you mean "new ..." ?
I meant declare, not define, sorry. Yes, the 'new ...' part.
Reply
#9

I forgot to put it, so here is what i did :
pawn Код:
new pTazer[MAX_PLAYERS];
And now :

Код:
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(1696) : error 021: symbol already defined: "pTazer"
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(22122) : error 028: invalid subscript (not an array or too many subscripts): "gTeam"
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(22122) : warning 215: expression has no effect
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(22122) : error 001: expected token: ";", but found "]"
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(22122) : error 029: invalid expression, assumed zero
C:\Users\Geo\Desktop\Ca marche\a jour\gamemodes\lairp.pwn(22122) : fatal error 107: too many error messages on one line
I have no idea of what i'm doing.
Reply
#10

You have declared pTazer somewhere else above the one you just added. The line is probably
pawn Код:
new pTazer;
If you press CTRL+F in pawno you can search through your script. Find the other declaration and delete it - unless it's used somewhere else.

You've done the same with gTeam - you've declared it as a normal variable
pawn Код:
new gTeam;
when you use it as an array
pawn Код:
gTeam[playerid]
to fix, simply add [MAX_PLAYERS] to the declaration, like so:
pawn Код:
new gTeam[MAX_PLAYERS];
I hope you understand.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)