i need help on this code
#1

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/lock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
        if(PlayerCar[playerid] != -1) //this is the line 313
        {
            LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
        }
        PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
        LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
        return 1;
    }
    if(!strcmp(cmdtext, "/unlock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
        PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
        LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
        return 1;
	)
	return 0;
)

Код:
C:\Documents and Settings\Administrador.EQUIPO\Bureau\grandlarc.pwn(313) : error 017: undefined symbol "PlayerCar"
C:\Documents and Settings\Administrador.EQUIPO\Bureau\grandlarc.pwn(313) : warning 215: expression has no effect
C:\Documents and Settings\Administrador.EQUIPO\Bureau\grandlarc.pwn(313) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Administrador.EQUIPO\Bureau\grandlarc.pwn(313) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrador.EQUIPO\Bureau\grandlarc.pwn(313) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

Did you copy-paste the code from somewhere? You should declare it:
pawn Код:
// global:
new PlayerCar[MAX_PLAYERS];


// NOTE: don't forget to reset it on connect..
and LockedCar should be declared too or else it will give you the same error (017).
Reply
#3

if you dont have that on top of script add it and should work
PHP код:
new PlayerCar[MAX_PLAYERS]; 
Reply
#4

The program cannot locate where the variable PlayerCar[] is located and so for him it doesn't exist. I'm assuming you have a problem defining this variable, so if you would please share the part where this variable is defined, that would be great.

Edit: Some other fellow members of the forums already answered your question before my page refreshed, it's the same anyways.
Reply
#5

thnx guyss for u reply but i just fix it and it gives no errors and no warning

pawn Код:
#include <a_samp>

new PlayerCar[MAX_PLAYERS], LockedCar[1000];
new Text:Locked;
new MsgLocked[MAX_PLAYERS], LockedTimer[MAX_PLAYERS];
forward RemoveLock(playerid);

public OnPlayerConnect(playerid)
{
    PlayerCar[playerid] = -1;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/lock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle."); // player has to be in a vehicle
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver."); // player has to be a driver
        if(PlayerCar[playerid] != -1)
        {
            LockedCar[PlayerCar[playerid]] = 0; // if player has any locked vehicle it will unlock it, allowing him to lock current vehicle - every player can have only one locked vehicle
        }
        PlayerCar[playerid] = GetPlayerVehicleID(playerid); // bounds vehicle to a player
        LockedCar[GetPlayerVehicleID(playerid)] = 1; // locks vehicle
        return 1;
    }
    if(!strcmp(cmdtext, "/unlock", true))
    {
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be inside a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid,0xFFFFFFAA,"You have to be a driver.");
        PlayerCar[playerid] = -1; // tells server that this player don't have any locked vehicle
        LockedCar[GetPlayerVehicleID(playerid)] = 0; // unlocks current vehicle
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(LockedCar[vehicleid] == 1 && PlayerCar[playerid] != vehicleid) // if player is trying to enter locked vehicle and he is not bound to that vehicle
    {
        if(MsgLocked[playerid] == 1) // if there's already message showing for player
        {
            TextDrawHideForPlayer(playerid, Locked); // hides message
            MsgLocked[playerid] = 0; // there's no more any message regarding locked car
            KillTimer(LockedTimer[playerid]); // kills timer
        }
        TogglePlayerControllable(playerid, true); // stops player from entering vehicle (it's not his vehicle, why should he enter it?)
        Locked = TextDrawCreate(10.0, 250.0, "This Vehicle is Locked"); // pretty much self-explanatory
        TextDrawUseBox(Locked, 1);
        TextDrawBoxColor(Locked, 0x00000055);
        TextDrawTextSize(Locked, 125, 5);
        TextDrawShowForPlayer(playerid, Locked); // shows TextDraw to player
        LockedTimer[playerid] = SetTimer("RemoveLock", 4000, false); // sets timer for hiding TextDraw
        MsgLocked[playerid] = 1; // we have TextDraw showing
    }
    return 1;
}

public RemoveLock(playerid)
{
    if(MsgLocked[playerid] == 1) // if there's message showing for player
    {
        TextDrawHideForPlayer(playerid, Locked); // hides message
        MsgLocked[playerid] = 0; // there's no more any message regarding locked car
    }
}

public OnVehicleSpawn(vehicleid)
{
    LockedCar[vehicleid] = 0; // when vehicle has respawned (nobody has entered it for a while) server will unlock it
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PlayerCar[i] == vehicleid)
            PlayerCar[i] = -1; // unbounds player from this vehicle so anyone can enter it
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)