25.02.2013, 16:53
The ProxDetector sends the message but the object is not created.
I'm really not sure at all.
pawn Код:
CMD:siren(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
if(Faction[playerid] != 1 && Faction[playerid] != 4) return SendClientMessage(playerid, COLOUR_GREY, "You cannot use this.");
new type,vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) != 426) return SendClientMessage(playerid, COLOUR_GREY, "This vehicle is not a 'Premier', Currently this is the only vehicle to place this on.");
if(sscanf(params, "d", type))return SendClientMessage(playerid, COLOUR_GREY, "USAGE: /siren [position] 1 = Roof, 2 = Inside, 3 = Removed.");
if(type < 1 || type > 3)return SendClientMessage(playerid, COLOUR_GREY, "Usage: /siren [position] (Position must be between 1 and 3)");
new string[128]; // creat this only if the syntax was correct, otherwise it's a waste;
if(type == 1)
{
if(Siren[vehicleid] == 1)return SendClientMessage(playerid, COLOUR_GREY, "There is already a siren on this vehicle.");
Siren[vehicleid] = 1;
SirenObject[vehicleid] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
AttachObjectToVehicle(SirenObject[vehicleid], vehicleid, -0.756499, 0.095000, 0.889999, 0.000000, 0.000000, 0.000000);
format(string, sizeof(string), "* %s puts the siren on the roof of the vehicle.", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE);
}
else if(type == 2)
{
if(Siren[vehicleid] == 1)return SendClientMessage(playerid, COLOUR_GREY, "There is already a siren on this vehicle.");
Siren[vehicleid] = 1;
SirenObject[vehicleid] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
AttachObjectToVehicle(SirenObject[vehicleid], vehicleid, 0.013500, 0.744999, 0.404999, 0.000000, 0.000000, 0.000000);
format(string, sizeof(string), "* %s puts the siren on the dashboard of the vehicle .", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE);
}
else if(type == 3)
{
if(Siren[vehicleid] == 0)return SendClientMessage(playerid, COLOUR_GREY, "There is no siren on this vehicle.");
Siren[vehicleid] = 0;
DestroyDynamicObject(SirenObject[vehicleid]);
format(string, sizeof(string), "* %s takes down the siren.", GetNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE,COLOUR_PURPLE);
}
return 1;
}