SA-MP Forums Archive
Vehicle loop problem :/ - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle loop problem :/ (/showthread.php?tid=280266)



Vehicle loop problem :/ - knackworst - 31.08.2011

hi, I was writing something that when a player from a team steals a car he gets +1 wanted level, so I made a vehicle variable to check if the vehicle is stolen:
pawn Код:
//other code
else if(vehicle == 516)
        {
            for(new iv; iv<MAX_VEHICLES; iv++)// a loop that goes though all vehicles
            {
                if(gTeam[playerid] == TEAM_BANDIT)
                {
                    if(stolenveh[iv] == 0)
                    {
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "U stole a Drivers car, be carefull!");
                        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
                        new string[128];
                        format(string,sizeof(string),"%s has stolen a drivers car!",playerid);
                        SendClientMessageToAllCops(string);
                        stolenveh[iv] = 1;
                        return 1;
                    }
                    else if(stolenveh[iv] == 1)
                    {
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "This vehicle has been stolen!");
                    }
                }
            }
        }//other code
this must protect the player from getting a double wanted level, while entered the same car...
however when I steal the car; it says the messages, u stolen a drivers car!
but when I enter that same car again, I get +1 wanted level and I get the u have stolen a drivers car message + this vehicle has been stolen message :/


Re: Vehicle loop problem :/ - TTJJ - 31.08.2011

Hi Knackworst,

If I understand your code correctlly... You may be able to just do this:
pawn Код:
if(gTeam[playerid] == TEAM_BANDIT)
{
    if(stolenveh[GetPlayerVehicleID(playerid)] == 0)
    {
        //Do vehicle stolen stuff
    }
    else if(stolenveh[GetPlayerVehcileID(playerid)] == 1)
    {
         //Do Other Vehicle Stolen Stuff
    }
}
Cheers,

TJ


Re: Vehicle loop problem :/ - =WoR=Varth - 31.08.2011

pawn Код:
new iv=1; iv<MAX_VEHICLES; iv++//There's no vehicleid 0
EDIT:Miss read.


Re: Vehicle loop problem :/ - knackworst - 31.08.2011

Quote:
Originally Posted by TTJJ
Посмотреть сообщение
Hi Knackworst,

If I understand your code correctlly... You may be able to just do this:
pawn Код:
if(gTeam[playerid] == TEAM_BANDIT)
{
    if(stolenveh[GetPlayerVehicleID(playerid)] == 0)
    {
        //Do vehicle stolen stuff
    }
    else if(stolenveh[GetPlayerVehcileID(playerid)] == 1)
    {
         //Do Other Vehicle Stolen Stuff
    }
}
Cheers,

TJ
and what do I put in here? : stolenveh[vehicleid] = 1;


Re: Vehicle loop problem :/ - =WoR=Varth - 31.08.2011

Your code ofc,
pawn Код:
if(gTeam[playerid] == TEAM_BANDIT)
{
    if(stolenveh[GetPlayerVehicleID(playerid)] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "U stole a Drivers car, be carefull!");
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
        new string[128];
        format(string,sizeof(string),"%s has stolen a drivers car!",playerid);
        SendClientMessageToAllCops(string);
        stolenveh[iv] = 1;
        return 1;
    }
    else if(stolenveh[GetPlayerVehcileID(playerid)] == 1) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "This vehicle has been stolen!");
}



Re: Vehicle loop problem :/ - knackworst - 31.08.2011

Doesn't work... I get the same message when I steal it and when I enter it the second time


Re: Vehicle loop problem :/ - =WoR=Varth - 31.08.2011

pawn Код:
if(gTeam[playerid] == TEAM_BANDIT)
{
    if(stolenveh[GetPlayerVehicleID(playerid)] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "U stole a Drivers car, be carefull!");
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
        new string[128];
        format(string,sizeof(string),"%s has stolen a drivers car!",playerid);
        SendClientMessageToAllCops(string);
        stolenveh[iv] = 1;
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "This vehicle has been stolen!");
}



Re: Vehicle loop problem :/ - FireCat - 31.08.2011

pawn Код:
else if(vehicle == 516)
        {
            for(new iv; iv<MAX_VEHICLES; iv++)// a loop that goes though all vehicles
            {
                if(gTeam[playerid] == TEAM_BANDIT)
                {
                    if(stolenveh[iv] == 1) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "This vehicle has been stolen!");
                    if(stolenveh[iv] == 0)
                    {
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "U stole a Drivers car, be carefull!");
                        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 1);
                        new string[128];
                        format(string,sizeof(string),"%s has stolen a drivers car!",playerid);
                        SendClientMessageToAllCops(string);
                        stolenveh[iv] = 1;
                        return 1;
                    }
                }
            }
        }//other code



Re: Vehicle loop problem :/ - knackworst - 31.08.2011

nope, still get same message when I reenter the car


Re: Vehicle loop problem :/ - =WoR=Varth - 31.08.2011

My bad.