SA-MP Forums Archive
[Ajuda] expected token - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] expected token (/showthread.php?tid=550915)



expected token - JoshNudock - 15.12.2014

Alguem pode me informar oque ouve?

Код:
C:\Documents and Settings\P.Henrique\Desktop\Nova pasta\gamemodes\BSL.pwn(870) : error 001: expected token: "]", but found "-integer value-"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
a linha й essa..

pawn Код:
new FirstKick[MAX_PLAYERS char];
tem tambйm essa define

pawn Код:
#define char 255



Re: expected token - MultiKill - 15.12.2014

Char serve para armazenar um ъnico caractere.

Mais sobre char.

O que vocк tentou fazer?

pawn Код:
new FirstKick[500 255]; // ?

//seria:
new FirstKick[MAX_PLAYERS];



Re: expected token - JoshNudock - 15.12.2014

https://sampforum.blast.hk/showthread.php?tid=466074


Re: expected token - MultiKill - 15.12.2014

Apague:
pawn Код:
#define char 255



Re: expected token - PT - 15.12.2014

Quote:
Originally Posted by MultiKill
Посмотреть сообщение
Char serve para armazenar um ъnico caractere.

Mais sobre char.

O que vocк tentou fazer?

pawn Код:
new FirstKick[500 255]; // ?

//seria:
new FirstKick[MAX_PLAYERS];
Errado..

-

Da uma leitura nisto

Quote:
Originally Posted by Slice
Посмотреть сообщение
"Char-arrays"
PAWN has a feature for accessing single bytes in arrays, intended for use with packed strings. Most SA-MP natives doesn't cover packed strings, though.
You can, however, utilize these arrays a lot for memory optimization. A normal array can store values between -2,147,483,648 and 2,147,483,647; you don't always need that capacity, do you?
With packed strings you can store values between 0-255 (yes, no negative values; -1 will wrap to 255). When you know you don't need negative values and won't ever exceed 255, why not save some memory?

pawn Код:
new bool:g_IsPlayerSomething[ MAX_PLAYERS ]; // 500 cells * 4 bytes per cell = 2000 bytes!
new bool:g_IsPlayerSomething[ MAX_PLAYERS char ]; // 500 bytes = .. 500 bytes!
If you use "char arrays" instead of normal ones where needed 50 times you'll save 75,000 bytes (~73 kb).

Note!
When accessing these arrays, you need to use curly brackets (aka braces) as opposed to the normal square brackets.
Example:
pawn Код:
public OnPlayerConnect( playerid )
{
    g_IsPlayerSomething{ playerid } = false;
//                     ^          ^
}

public OnPlayerSpawn( playerid )
{
//                          v          v
    if ( g_IsPlayerSomething{ playerid } )
    {
        // ..
    }
}