07.08.2011, 17:13
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include <zcmd>
#define red 0xAA3333AA //Change this to the error color you want.
#define COLOR_PURPLE 0xC2A2DAAA //prox detector color
new gLastCar[MAX_PLAYERS];
stock IsABoat(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 430,446,452,453,454,472,473,484,493,595: return 1;
}
return 0;
}
stock IsAPlane(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 460,464,476,511,512,513,519,520,553,577,592,593: return 1;
}
return 0;
}
stock IsAHelicopter(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 417,425,447,465,469,487,488,497,501,548,563: return 1;
}
return 0;
}
stock IsATrain(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 449,537,538,569,570,590: return 1;
}
return 0;
}
stock IsABike(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 448,461,462,463,468,521,522,523,581,586,481,409,510: return 1;
}
return 0;
}
stock IsPlayerDriver(playerid)
{
if(IsPlayerConnected(playerid) && GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
return 1;
}
return 0;
}
stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
new invehicle[MAX_PLAYERS];
new virtualworld = GetPlayerVirtualWorld(playerid);
new interior = GetPlayerInterior(playerid);
new vehicleid = GetPlayerVehicleID(playerid);
new ivehicleid;
if(vehicleid)
{
GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
}
else
{
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
vehicleid = GetPlayerVehicleID(playerid);
}
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerVirtualWorld(i) == virtualworld)
{
if((GetPlayerInterior(i) == interior))
{
if(vehicleid)
{
if(IsPlayerInVehicle(i,vehicleid))
{
invehicle[i] = 1;
}
}
if(!invehicle[i])
{
if(IsPlayerInAnyVehicle(i))
{
ivehicleid = GetPlayerVehicleID(i);
GetVehiclePos(ivehicleid,posx,posy,posz);
} else {
GetPlayerPos(i,posx,posy,posz);
}
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, string);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, string);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, string);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, string);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, string);
}
}
else
{
SendClientMessage(i, col1, string);
}
}
}
} else {
SendClientMessage(i, col1, string);
}
}
}
return 1;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------------");
print("| Vehicle Control System - By Jack_Leslie |");
print("--------------------------------------------\n");
ManualVehicleEngineAndLights();
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
{
new newcar = GetPlayerVehicleID(playerid);
gLastCar[playerid] = newcar;
}
return 1;
}
/*CMD:objective(playerid, params[])
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(!IsPlayerDriver(playerid))
{
SendClientMessage(playerid,red,"[Vehicle Control] You're not in a Vehicle to control the lights!");
return 1;
}
else if(IsPlayerDriver(playerid))
{
if(objective != 1)
{
objective = 1;
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_ON);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's objective {2F991A}on!");
return 1;
}
else
{
objective = 0;
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_OFF);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's objective {E31919}off!");
return 1;
}
}
return objective;
}*/ // Commented due to Non-RP on Roleplay Servers, feel free to un-comment if you wish to use it.
CMD:lights(playerid, params[])
{
new string[128];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(!IsPlayerDriver(playerid))
{
SendClientMessage(playerid,red,"[Vehicle Control] You're not in a Vehicle to control the lights!");
return 1;
}
else if(IsPlayerDriver(playerid))
{
if(lights != 1)
{
lights = 1;
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's lights {2F991A}on!");
format(string, sizeof(string), "* %s flicks a switch on the dashboard, switching on their lights.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
lights = 0;
SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've turned the vehicle's lights {E31919}off!");
format(string, sizeof(string), "* %s flicks a switch on the dashboard, switching off their lights.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
}
return lights;
}
CMD:hood(playerid, params[])
{
new string[128];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new engine,lights,alarm,doors,bonnet,boot,objective;
new oldcar = gLastCar[playerid];
new Float:cX, Float:cY, Float:cZ;
GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
GetVehiclePos(oldcar, cX, cY, cZ);
new vehicleid = GetPlayerVehicleID(playerid);
if(!IsAPlane(vehicleid) || !IsAHelicopter(vehicleid) || !IsABike(vehicleid) || !IsATrain(vehicleid) || !IsABoat(vehicleid))
{
if(IsPlayerDriver(playerid) || IsPlayerInRangeOfPoint(playerid, 5, cX-2, cY, cZ))
{
if(bonnet != 1)
{
bonnet = 1;
SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've opened the hood!");
format(string, sizeof(string), "* %s opens up the hood of the car.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
bonnet = 0;
SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've shut the hood!");
format(string, sizeof(string), "* %s closes the hood of the car.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
}
}
return bonnet;
}
CMD:trunk(playerid, params[])
{
new string[128];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new engine,lights,alarm,doors,bonnet,boot,objective;
new oldcar = gLastCar[playerid];
new Float:cX, Float:cY, Float:cZ;
GetVehicleParamsEx(oldcar, engine, lights, alarm, doors, bonnet, boot, objective);
GetVehiclePos(oldcar, cX, cY, cZ);
new vehicleid = GetPlayerVehicleID(playerid);
if(!IsAPlane(vehicleid) || !IsAHelicopter(vehicleid) || !IsABike(vehicleid) || !IsATrain(vehicleid) || !IsABoat(vehicleid))
{
if(IsPlayerDriver(playerid) || IsPlayerInRangeOfPoint(playerid, 5, cX+2, cY, cZ))
{
if(boot != 1)
{
boot = 1;
SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've opened the trunk!");
format(string, sizeof(string), "* %s opens up the trunk of the car.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
boot = 0;
SetVehicleParamsEx(oldcar,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective);
SendClientMessage(playerid, 0xFFFFFFAA, "[Vehicle Control] You've shut the trunk!");
format(string, sizeof(string), "* %s closes the trunk of the car.", sendername);
ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
}
}
return boot;
}
BTW: Thanks for this pwn code. For me it is really usefull too.
![Cheesy](images/smilies/biggrin.png)