OnPlayerStateChange
#1

^^^^^^^^
Reply
#2

AdminCar[playerid]
Reply
#3

When you put arrays you must use index it

Код:
defining

new WHATEVER[NUMBER_OF_SLOTS] //MAX_VEHICLES i think it is 2000

storing variables in the array:
WHATEVER[0] = CreateVehicle(..); //THE ARRAY SLOT 0
WHATEVER[1] = CreateVehicle(..); //THE ARRAY SLOT 0
WHATEVER[2] = CreateVehicle(..); //THE ARRAY SLOT 0

//note: do not cross the limit when you storing the data (the array id must be lover for 1 of the number of slots in the array), in this case the "NUMBER_OF_SLOTS" is 3 - 3 slots;

checking:

if(GetPlayerVehicleID(playerid) == WHATEVER[THE_ARRAY_ID_TO_CHECK_THE_DATA_THAT-IS_STORED_IN_THE_ARRAY_ID])
Reply
#4

^^^^^^^^
Reply
#5

Bump
Reply
#6

AdminCar; not AdminCar[MAX_PLAYERS];
Reply
#7

Assuming there are more than one admin vehicles.

pawn Код:
#define MAX_ADMIN_VEHICLES 3

new AdminCar[MAX_ADMIN_VEHICLES];
pawn Код:
public OnFilterScriptInit()
{
    AdminCar[0] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
    AdminCar[1] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
    AdminCar[2] = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
    return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && IsAdminVehicle(GetPlayerVehicleID(playerid)))
    {
        if(!IsCnRAdmin(playerid))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to you.");
        }
    }
    return 1;
}
pawn Код:
IsAdminVehicle(vehicleid)
{
    for(new i; i < MAX_ADMIN_VEHICLES; i++)
    {
        if(vehicleid == AdminCar[i])
        {
            return true;
        }
    }
    return false;
}
Reply
#8

Use this
pawn Код:
#include <a_samp>

new AdminCar[3];
enum PlayerInfo
{
    Admin
}
new PlayerData[MAX_PLAYERS][PlayerInfo];

public OnFilterScriptInit()
{
    AdminCar[0] = CreateVehicle(...);
    AdminCar[1] = CreateVehicle(...);
    AdminCar[2] = CreateVehicle(...);
    return 1;
}

public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    if(PlayerData[playerid][Admin] == 0)
    {
        for(new i; i < sizeof(AdminCar); i++)
        {
            if(GetPlayerVehicleID(playerid) == i)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, 0x281aeb, "This vehicle doesn't belong to ");
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)