PDA

View Full Version : Command(s) not working


aoky
08/07/2017, 05:39 PM
CMD:siren(playerid, params[])
{
new model = GetVehicleModel(vehicle);
if(!IsLawEnforcement(playerid)) return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");
if(!IsDriver(playerid)) return SCM(playerid, COLOR_GREY, "You must be the driver.");
{
if(model != 560 && model != 541 && model != 525 && model != 426 && model != 579) return SCM(playerid, COLOR_GREY, "The siren is compatible only for Sultan/Bullet/Towtruck/Premier/Huntley.");
if(!IsDriver(playerid)) return SCM(playerid, COLOR_GREY, "You must be the driver.");
if(Siren[vehicle] == 0)
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
if(model == 560)
{
Siren[vehicle] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.225000,0.750000,0.449999, 0.000000, 0.000000, 0.000000);
}
if(model == 541)
{
Siren[vehicle] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.375000,0.524999,0.375000, 0.000000, 0.000000, 0.000000);
}
if(model == 426)
{
Siren[vehicle] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.524999,0.749999, 0.375000, 0.000000, 0.000000, 0.000000);
}
if(model == 525)
{
Siren[vehicle] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.0, -0.485, 1.36, 0.000000, 0.000000, 180.0);
}
if(model == 579)
{
Siren[vehicle] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.679999, 0.479999, 0.734999, 0.000000, 0.000000, 0.000000);
}
}
else
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren[vehicle]);
Siren[vehicle] = 0;
}
}
{
if(model != 490) return SCM(playerid, COLOR_GREY, "The siren is compatible only for Rancher.");
if(!IsDriver(playerid)) return SCM(playerid, COLOR_GREY, "You must be the driver.");
if(Siren[vehicle] == 0)
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
Siren[vehicle] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vehicle], vehicle, 0.654999, 1.149999, 0.594999, 0.000000, 0.000000, 0.000000);
}
else
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren[vehicle]);
Siren[vehicle] = 0;
}
}
return 1;
}

CMD:siren2(playerid, params[])
{
new model = GetVehicleModel(vehicle);
if(!IsLawEnforcement(playerid)) return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");
if(model != 560 && model != 426) return SCM(playerid, COLOR_GREY, "The siren is compatible only for Sultan/Premier.");
if(!IsDriver(playerid)) return SCM(playerid, COLOR_GREY, "You must be the driver.");
if(Siren2[vehicle] == 0)
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
if(model == 560)
{
Siren2[vehicle] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren2[vehicle], vehicle, 0.000000, -1.289999, 0.394999, 0.000000, 0.000000, 0.000000);
}
if(model == 426)
{
Siren2[vehicle] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren2[vehicle], vehicle, 0.000000, -1.669998, 0.349999, 0.000000, 0.000000, 0.000000);
}
}
else
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren2[vehicle]);
Siren2[vehicle] = 0;
}
return 1;
}



It's resulting in this:
https://www.upload.ee/image/7204871/sa-mp-040.png

StaticYey
08/07/2017, 05:46 PM
Nevermind

Freedom.
08/07/2017, 05:55 PM
CMD:siren(playerid, params[])
{
new vID = GetPlayerVehicleID(playerid);
new vModel = GetVehicleModel(vID);

if(!IsLawEnforcement(playerid))
return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");

if(!IsDriver(playerid))
return SCM(playerid, COLOR_GREY, "You must be the driver.");

if(vModel != 560 && vModel != 541 && vModel != 525 && vModel != 426 && vModel != 579)
return SCM(playerid, COLOR_GREY, "The siren is compatible only for Sultan/Bullet/Towtruck/Premier/Huntley.");

switch (Siren[vModel])
{
case 0:
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
switch(vModel)
{
case 560:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.225000,0.750000,0.449999, 0.000000, 0.000000, 0.000000);
}
case 541:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.375000,0.524999,0.375000, 0.000000, 0.000000, 0.000000);
}
case 426:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.524999,0.749999, 0.375000, 0.000000, 0.000000, 0.000000);
}
case 525:
{
Siren[vModel] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.0, -0.485, 1.36, 0.000000, 0.000000, 180.0);
}
case 579:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.679999, 0.479999, 0.734999, 0.000000, 0.000000, 0.000000);
}
}
}
default:
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren[vModel]);
Siren[vModel] = 0;
}
}
return 1;
}

jlalt
08/07/2017, 06:00 PM
You are not getting player vehicle id at all idk from where you got vehicle var but assign it by GetPlayerVehicleID(playerid); also check if player is in vehicle before that by IsplayerInAnyVehcile(playerid);

new model = GetVehicleModel(vehicle);


->


vehicle = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicle);


@Freedom. You're using switch only to check if a var equals to 0? Facepalm brother.

aoky
08/07/2017, 06:06 PM
CMD:siren(playerid, params[])
{
new vID = GetPlayerVehicleID(playerid);
new vModel = GetVehicleModel(vID);

if(!IsLawEnforcement(playerid))
return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");

if(!IsDriver(playerid))
return SCM(playerid, COLOR_GREY, "You must be the driver.");

if(vModel != 560 && vModel != 541 && vModel != 525 && vModel != 426 && vModel != 579)
return SCM(playerid, COLOR_GREY, "The siren is compatible only for Sultan/Bullet/Towtruck/Premier/Huntley.");

switch (Siren[vModel])
{
case 0:
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
switch(vModel)
{
case 560:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.225000,0.750000,0.449999, 0.000000, 0.000000, 0.000000);
}
case 541:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.375000,0.524999,0.375000, 0.000000, 0.000000, 0.000000);
}
case 426:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.524999,0.749999, 0.375000, 0.000000, 0.000000, 0.000000);
}
case 525:
{
Siren[vModel] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.0, -0.485, 1.36, 0.000000, 0.000000, 180.0);
}
case 579:
{
Siren[vModel] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[vModel], vModel, 0.679999, 0.479999, 0.734999, 0.000000, 0.000000, 0.000000);
}
}
}
default:
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren[vModel]);
Siren[vModel] = 0;
}
}
return 1;
}
That doesn't apply the dynamic object, it just says "Siren attached"

Freedom.
08/07/2017, 06:18 PM
My bad. This should work.

CMD:siren(playerid, params[])
{
new veh_ID = GetPlayerVehicleID(playerid);
new veh_model = GetVehicleModel(veh_ID);

if(!IsLawEnforcement(playerid))
return SCM(playerid, COLOR_LIGHTRED, "Invalid faction.");

if(!IsDriver(playerid))
return SCM(playerid, COLOR_GREY, "You must be the driver.");

if(veh_model != 560 && veh_model != 541 && veh_model != 525 && veh_model != 426 && veh_model != 579)
return SCM(playerid, COLOR_GREY, "The siren is compatible only for Sultan/Bullet/Towtruck/Premier/Huntley.");

if(Siren[veh_ID] == 0)
{
SCM(playerid, COLOR_WHITE, "Siren attached.");
switch(veh_model)
{
case 560:
{
Siren[veh_ID] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachDynamicObjectToVehicle(Siren[veh_ID], veh_ID, 0.225000,0.750000,0.449999, 0.000000, 0.000000, 0.000000);
}
case 541:
{
Siren[veh_ID] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[veh_ID], veh_ID, 0.375000,0.524999,0.375000, 0.000000, 0.000000, 0.000000);
}
case 426:
{
Siren[veh_ID] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[veh_ID], veh_ID, 0.524999,0.749999, 0.375000, 0.000000, 0.000000, 0.000000);
}
case 525:
{
Siren[veh_ID] = CreateDynamicObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[veh_ID], veh_ID, 0.0, -0.485, 1.36, 0.000000, 0.000000, 180.0);
}
case 579:
{
Siren[veh_ID] = CreateDynamicObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, -1, 300.0);
AttachDynamicObjectToVehicle(Siren[veh_ID], veh_ID, 0.679999, 0.479999, 0.734999, 0.000000, 0.000000, 0.000000);
}
}
}
else
{
SCM(playerid, COLOR_WHITE, "Siren detached.");
DestroyDynamicObject(Siren[veh_ID]);
Siren[veh_ID] = 0;
}
return 1;
}