Vehicle system help
#1

Whenever any player takes away my car, and then i try to spawn a new car (The same that the player took), it brings the other player back to me and it appears that his car was jacked.

I can't figure out where is the problem.
This is the car code.
pawn Код:
COMMAND:v(playerid,params[])
{
    if(isnull(params))
    {
        SendClientMessage(playerid,0x6FFF00FF, "{F07F1D}USAGE: {BBFF00}/v <Vehicle Name/Vehicle ID>");
        return 1;
    }
    if(IsNumeric(params) && (strval(params) < 400 || strval(params) > 611))
    {
        SendClientMessage(playerid,COLOR_WHITE,""RED"ERROR: "GREY"You have entered a wrong vehicle name/vehicle ID!");
        return 1;
    }
    if(!IsNumeric(params) && (GetVehicleModelIdFromName(params) < 400 || GetVehicleModelIdFromName(params) > 611))
    {
        SendClientMessage(playerid,COLOR_WHITE,""RED"ERROR: "GREY"You have entered a wrong vehicle name/vehicle ID!");
        return 1;
    }
    for(new X = 0; X < sizeof(WrongVehicles); X++)
    {
        if(IsNumeric(params) && strval(params) == WrongVehicles[X])
        {
            SendClientMessage(playerid,COLOR_WHITE,""RED"ERROR: "GREY"You have entered a wrong vehicle name/vehicle ID!");
            return 1;
        }
        if(!IsNumeric(params) && GetVehicleModelIdFromName(params) == WrongVehicles[X])
        {
            SendClientMessage(playerid,COLOR_WHITE,""RED"ERROR: "GREY"You have entered a wrong vehicle name/vehicle ID!");
            return 1;
        }
    }
    new String[300];
    if(IsNumeric(params) && (strval(params) > 399 || strval(params) < 612))
    {
        CreatePlayerVehicle(playerid,strval(params));
        format(String,300,""YELLOW">> {34FACF}You have spawned a {34FAE3}%s (ID: %d){34FACF}.",VehicleNames[strval(params) - 400],strval(params));
    }
    if(!IsNumeric(params) && (GetVehicleModelIdFromName(params) > 399 || GetVehicleModelIdFromName(params) < 612))
    {
        CreatePlayerVehicle(playerid,GetVehicleModelIdFromName(params));
        format(String,300,""YELLOW">> {34FACF}You have spawned a {34FAE3}%s (ID: %d){34FACF}"".",VehicleNames[GetVehicleModelIdFromName(params) - 400],GetVehicleModelIdFromName(params));
    }
    SendClientMessage(playerid,COLOR_WHITE,String);
    return 1;
}
OnPlayerStateChange
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(IsBeingSpeced[playerid] == 1)
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if(spectatorid[i] == playerid)
                {
                    PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));
                }
            }
        }
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
        if(IsBeingSpeced[playerid] == 1)//If the player being spectated, exists a vehicle, then let the spectator spectate the player.
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if(spectatorid[i] == playerid)
                {
                    PlayerSpectatePlayer(i, playerid);// Letting the spectator, spectate the player who exited the vehicle.
                }
            }
        }
    }
    if (AntifallEnabled[playerid] == 1)
    {
        if (oldstate == PLAYER_STATE_ONFOOT)
        {
            if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
            {
                inVehicle[playerid] = 1;
                carID[playerid] = GetPlayerVehicleID(playerid);
            }
        }
        if (oldstate == PLAYER_STATE_DRIVER)
        {
            if (newstate == PLAYER_STATE_ONFOOT)
            {
                if (inVehicle[playerid] == 1)
                {
                    PutPlayerInVehicle(playerid, carID[playerid], 0);
                }
            }
        }
        if (oldstate == PLAYER_STATE_PASSENGER)
        {
            if (newstate == PLAYER_STATE_ONFOOT)
            {
                if (inVehicle[playerid] == 1)
                {
                    PutPlayerInVehicle(playerid, carID[playerid], 1);
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)