Need help fixing bugs
#1

1) I can't enter all the vehicles
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    new score = GetPlayerScore(playerid);
    new Float:x,Float:y,Float:z;
    if(veh == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 447 && veh == 432 || score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    return 1;
}
2) I'm Los Santos gang member. But I can see a message says "[WARNING]You have entered San Fierro Area". But I'm at Los Santos.
pawn Код:
public OnPlayerEnterArea(playerid, areaid)
{
    new gang = GetPlayerTeam(playerid);
    if(areaid == lsarea && gang == Las_Venturas_Gang_Members && gang == San_Fierro_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Los Santos Area");
        return 1;
    }
    else if(areaid == sfarea || gang == Las_Venturas_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered San Fierro Area");
        return 1;
    }
    else if(areaid == lvarea || gang == San_Fierro_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Las Venturas Area");
        return 1;
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
1) I can't enter all the vehicles
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    new score = GetPlayerScore(playerid);
    new Float:x,Float:y,Float:z;
    if(veh == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 447 && veh == 432 || score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    return 1;
}
2) I'm Los Santos gang member. But I can see a message says "[WARNING]You have entered San Fierro Area". But I'm at Los Santos.
pawn Код:
public OnPlayerEnterArea(playerid, areaid)
{
    new gang = GetPlayerTeam(playerid);
    if(areaid == lsarea && gang == Las_Venturas_Gang_Members && gang == San_Fierro_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Los Santos Area");
        return 1;
    }
    else if(areaid == sfarea || gang == Las_Venturas_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered San Fierro Area");
        return 1;
    }
    else if(areaid == lvarea || gang == San_Fierro_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Las Venturas Area");
        return 1;
    }
    return 1;
}
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new model = GetVehicleModel(vehicleid),
        score = GetPlayerScore(playerid);

    if(model == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if(model == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if(model = 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if((model == 447 || model == 432) && score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        ClearAnimations(playerid);
    }
    return 1;
}
As you can see I've changed the last one there. Instead of || score < 150 What || score < 150 was doing was making it so if you don't have a score more than 150, you can't enter ANY vehicle. Also, you were doing if those two vehicle ids were exactly the same...Which won't happen. Another thing to note is, players don't actually have a vehicle ID yet as they haven't gotten into the vehicle. That would be something for OnPlayerStateChange then remove them instead of reset their position.


#2 I don't know what's going on in there...You have some gang variable that's global that will constantly change from player to play becoming a completely useless variable. You should look for tutorials on arrays for that one.
Reply
#3

Ok thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)