[Qeustion]about (I don't know how that call)
#1

Hi,

How that called and how it using
Код:
new test[2][2]={
{"text",11},
{"text",11}
};
Код:
new myvehicleid[3][1]={
{411},
{412},
{413}
};
And exsample I need how to create these id's cars using key_states

Thanks, thanks in advance
Reply
#2

That are arrays, there is a sa-mp wiki page about them

But what you want to do is something different, you want to assign vehicleids for you or for a group, dont you ?
Reply
#3

First thanks.
I want make vehicle id list, witch i could vehile spawing
example

new vData[4][1]=

{

{565},
{ 589 },
{561},
{ 584 }

};

if(PREESED(key_up))
{


// and i want to make here car in succession using vData array
}
Reply
#4

Ah okay, that isnt difficult

Since you only got one row you dont need a second dimension

pawn Код:
// stock: Like new, just that the code doesnt get compiled if not used
// const: Declares the data as constant (cant be changed) => better performance
stock const vData[] = {
    565, 589, 561, 584
};
Thats enough

And now to the key code
pawn Код:
// In some timer because up, down, left and right doesnt get called by OnPlayerKeyStateChange
    new
        keys,
        updown,
        leftright;
    if(GetPlayerKeys(playerid, keys, updown, leftright)) { // checks if the player is connected
        static // static: creates a local variable which behaves like a global one
            vDataIdx[MAX_PLAYERS];
        if(updown != 0) { // if the player isnt standing
            // Example code - a print statement which shows the current model
            print("Current vehicle model %d", vData[vDataIdx[playerid]]);
            // Just do here whatever you want, for a vehicle selection use CreateVehicle
            if(updown < 0) { // if the player pressed forward
                if(++vDataIdx[playerid] == sizeof vData) { // if we reach the first invalid index
                    vDataIdx[playerid] = 0; // We set it to the first valid index
                }
            } else { // ... pressed backwards
                if(--vDataIdx[playerid] == -1) { // if we reach the first invalid index
                    vDataIdx[playerid] = (sizeof vData - 1); // We set it to the last valid index
                }
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)