SA-MP Forums Archive
Stock for carveh? - 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: Stock for carveh? (/showthread.php?tid=550200)



Stock for carveh? - TiXz0r - 11.12.2014

How to make stock for
Код:
if(vehicleid == CopVeh || vehicleid == CopVeh2 || vehicleid == CopVeh3 || vehicleid == CopVeh4 || vehicleid == CopVeh5 || vehicleid == CopVeh6 || vehicleid == CopVeh7 || vehicleid == CopVeh8 || vehicleid == CopVeh9 || vehicleid == CopVeh10 || vehicleid == CopVeh11)
i want to use

Код:
if(vehicleid == CopVehs)
like:

Код:
stock vAutoskola(carid)
{
for(new iIdx = 0; iIdx < sizeof(AutoSkola); iIdx++)
{
if (AutoSkola[iIdx] == carid) return 1;
}
return 0;
}



Re: Stock for carveh? - Dziugsas - 11.12.2014

Its very hard unless you do something like this

pawn Код:
new CopCar[11];

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new v;v < 11;v++)
    {
        if(vehicleid == CopCar[v])
        {
            SendClientMessage(playerid,-1,"You have entered a police vehicle.");
        }
    }
    return 1;
}
its just a concept how it should look.


Re: Stock for carveh? - dominik523 - 11.12.2014

Please use loops:
pawn Код:
// new CopVeh[10];
// CopVeh[0] = ...
stock IsCopVeh(vehicleid)
{
    for(i = 0; i<10; i++)
    {
        if(vehicleid == CopVeh[i])
        {
            return 1;
        }
    }
    return 0;
}
Example:
pawn Код:
if(IsCopVeh(vehicleid)) // or if(IsCopVeh(GetPlayerVehicleID(playerid)))
// do something



Re: Stock for carveh? - TiXz0r - 11.12.2014

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Please use loops:
pawn Код:
// new CopVeh[10];
// CopVeh[0] = ...
stock IsCopVeh(vehicleid)
{
    for(i = 0; i<10; i++)
    {
        if(vehicleid == CopVeh[i])
        {
            return 1;
        }
    }
    return 0;
}
Example:
pawn Код:
if(IsCopVeh(vehicleid)) // or if(IsCopVeh(GetPlayerVehicleID(playerid)))
// do something
Hvala Dominik


Re: Stock for carveh? - TiXz0r - 11.12.2014

ERROR:

(1451) : error 017: undefined symbol "i"


Re: Stock for carveh? - Dziugsas - 11.12.2014

new i - in the loop.


Re: Stock for carveh? - TiXz0r - 11.12.2014

Код:
stock IsCopVeh(vehicleid)
{
    for(new i = 0; i<10; i++)
    {
        if(vehicleid == CopVeh[i])
        {
            return 1;
        }
    }
    return 0;
}
like this?


Re: Stock for carveh? - Dziugsas - 11.12.2014

yes sir.


Re: Stock for carveh? - TiXz0r - 11.12.2014

how to use in checkpoint?

Код:
    if(lspdposao[playerid] == 1 && IsPlayerInRangeOfPoint(playerid, 3.0, 644.1205,-544.9807,15.9353))
this?

if(lspdposao[playerid] == 1 && IsPlayerInRangeOfPoint(playerid, 3.0, 644.1205,-544.9807,15.9353) && CopVeh[i])


Re: Stock for carveh? - Dziugsas - 11.12.2014

if(lspdposao[playerid] == 1 && IsPlayerInRangeOfPoint(playerid, 3.0, 644.1205,-544.9807,15.9353) && IsCopVeh(CopVeh[vehicleid])