[Ajuda] expected token
#5

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 } )
    {
        // ..
    }
}
Reply


Messages In This Thread
expected token - by JoshNudock - 15.12.2014, 17:29
Re: expected token - by MultiKill - 15.12.2014, 17:34
Re: expected token - by JoshNudock - 15.12.2014, 18:10
Re: expected token - by MultiKill - 15.12.2014, 18:23
Re: expected token - by PT - 15.12.2014, 19:10

Forum Jump:


Users browsing this thread: 1 Guest(s)