SA-MP Forums Archive
Siren command - 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: Siren command (/showthread.php?tid=473556)



Siren command - Lajko1 - 03.11.2013

Umm hey guys I'm trying to make siren command but how should I define some of cars as "undercover cars" for now I have 4 cars

pawn Код:
new vehicle[4];
How can I define those cars as undercover cars so I can do only If(vehicleid == UnderCoverCar ....
Is this even possible ? :P
Thanks for help in advance


Re: Siren command - papedo - 03.11.2013

please post more information what should be a "undercover car".. it doesnґt make sense..


Re: Siren command - AlonzoTorres - 03.11.2013

pawn Код:
enum vehicleVars{        
    vUndercover,
}  
new vehicleInfo[MAX_VEHICLES][vehicleVars];


if(vehicleInfo[vehicleid][vUndercover] == 1){
  ...
}
And in the enum you would have coordinates and other information about the vehicle and if you want you can save and load that info. Just make sure you understand the ID system of vehicles in SA-MP.


Re: Siren command - Tagathron - 03.11.2013

Код:
new Undercover[MAX_VEHICLES]; //variable for making vehicles undercover
//.....
new veh1 = CreateVehicle(...); // Create a vehicle
Undercover[veh1]=1; // you can use 1-true and 0-false to control it,here you make that vehicle undercover
Or the thing that Alonzo did,just you don't need to use an enum for 1 variable


Re: Siren command - Lajko1 - 03.11.2013

Quote:
Originally Posted by papedo
Посмотреть сообщение
please post more information what should be a "undercover car".. it doesnґt make sense..
What am I trying to do is to conver this:
pawn Код:
if(GetPlayerVehicleID(vehicleid) != vehicle[0] || vehicle[1] || vehicle[2] || vehicle[3])
To something easier all those cars vehicle[0] - [4] are as undercover vehicles so how can I detect all those vehicles as Undercover so I don't need to do code like I posted above, because I want to add more cars like 10 so is there different way than doing vehicleid[1] || vehicleid[2]........vehicleid[6] vehicleid[7] ..... vehicleid[10] and so on I want all those cars detected as undercover cars.. so I can do only != UnderCoverCar) { code....}

Thanks for help.


Re: Siren command - AlonzoTorres - 03.11.2013

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
What am I trying to do is to conver this:
pawn Код:
if(GetPlayerVehicleID(vehicleid) != vehicle[0] || vehicle[1] || vehicle[2] || vehicle[3])
To something easier all those cars vehicle[0] - [4] are as undercover vehicles so how can I detect all those vehicles as Undercover so I don't need to do code like I posted above, because I want to add more cars like 10 so is there different way than doing vehicleid[1] || vehicleid[2]........vehicleid[6] vehicleid[7] ..... vehicleid[10] and so on I want all those cars detected as undercover cars.. so I can do only != UnderCoverCar) { code....}

Thanks for help.
The code I wrote above can hold up to 2000 vehicles (SA-MP does not support more).


Re: Siren command - Lajko1 - 03.11.2013

Quote:
Originally Posted by AlonzoTorres
Посмотреть сообщение
The code I wrote above can hold up to 2000 vehicles (SA-MP does not support more).
Okay but how I can put my cars in your code? these are my current cars
pawn Код:
vehicle[0] = AddStaticVehicle(477,1601.6586,-1688.0300,5.6453,90.2666,0,0); // ZR350 1 - Black
    vehicle[1] = AddStaticVehicle(477,1601.6870,-1683.8280,5.6452,90.6299,0,0); // ZR350 2 - Black
    vehicle[2] = AddStaticVehicle(560,1585.2329,-1667.4893,5.5978,270.7180,0,0); // Sultan 1 - Black
    vehicle[3] = AddStaticVehicle(560,1585.2502,-1671.7484,5.5982,269.6357,0,0); // Sultan 2 - Black



Re: Siren command - Lajko1 - 03.11.2013

Sorry for double post but can I define group of undercover vehicles like this too?

pawn Код:
stock IsUnderCoverCar(vehicleid)
{
    if(vehicleid == vehicle[0] || vehicleid == vehicle[1] || vehicleid == vehicle[2] || vehicleid == vehicle[3])
    {
    return 1;
    }
return 0;
}



Re: Siren command - AlonzoTorres - 03.11.2013

Well if you want static vehicles you can just define the variables directly,

pawn Код:
#define MAX_VEHICLES 2000


enum vehicleVars{
    vModel,
    vX,
    vY,
    vZ,
    vR,
    vColor1,
    vColor2,
    vUndercover,
}  
new vehicleInfo[MAX_VEHICLES][vehicleVars];


// ZR350 1 - Black
vehicleInfo[0][vModel] = 477;
vehicleInfo[0][vX] = 1601.6586;
vehicleInfo[0][vY] = -1688.0300;
vehicleInfo[0][vZ] = 5.6453;
vehicleInfo[0][vR] = 90.2666;
vehicleInfo[0][vColor1] = 0;
vehicleInfo[0][vColor2] = 0;

// Sultan 1 - Black
vehicleInfo[1][vModel] = 560;
vehicleInfo[1][vX] = 1585.2329;
vehicleInfo[1][vY] =  -1667.4893;
vehicleInfo[1][vZ] = 5.5978;
vehicleInfo[1][vR] = 270.7180;
vehicleInfo[1][vColor1] = 0;
vehicleInfo[1][vColor2] = 0;

// Sultan 2 - Black
vehicleInfo[2][vModel] = 560;
vehicleInfo[2][vX] = 1585.2502;
vehicleInfo[2][vY] =  -1671.7484;
vehicleInfo[2][vZ] = 5.5982;
vehicleInfo[2][vR] = 269.6357;
vehicleInfo[2][vColor1] = 0;
vehicleInfo[2][vColor2] = 0;


for(new vehicle = 0; vehicle < MAX_VEHICLES; vehicle++){
CreateVehicle(vehicleInfo[vehicle][vModel], vehicleInfo[vehicle][vX], vehicleInfo[vehicle][vY], vehicleInfo[vehicle][vZ], vehicleInfo[vehicle][vR],  vehicleInfo[vehicle][vColor1], vehicleInfo[vehicle][vColor2], 0);
}


stock IsUnderCoverCar(vehicleid)
{
if(vehicleInfo[vehicleid][vUndercover] == 1){

}
return 1;
}
Even better if you saved to files/database and made it dynamic, but always start basic and learn from there, hope this works for you.


Re: Siren command - Lajko1 - 03.11.2013

Okay I tried with stock I posted above and it's not working :/

here is the testing code
pawn Код:
if(strcmp(cmd, "/siren", true) == 0)
    {
        new vehicleid = GetVehicleModel(vehicleid);
        if(IsPlayerConnected(playerid))
        {
            if(GetPlayerVehicleID(vehicleid) != IsUnderCoverCar(vehicleid))
            {
                //
            }
            new x_nr[256]; // number
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr)) // if number is not entered player will get error message
            {
                SendClientMessage(playerid,0xFF0000AA,"Choose type for siren: 1 - Dashboard, 2 - Roof!"); // error message
                return 1;
            }
            else if(strcmp(x_nr,"1",true) == 0) // if they will enter /siren 1 object will be placed inside of car
            {
                //
            }
            else if(strcmp(x_nr,"2",true) == 0) // if they will enter /siren 2 object will be on roof
            {
                //
            }
        }
        }
        return 1;
    }
my compiler crashed when I tried to compile this code.