25.08.2013, 22:22
(
Последний раз редактировалось horsemeat; 26.08.2013 в 15:26.
Причина: new information
)
I am having problems making a /trunk command and a /hood command. The command works when you spawn a car and not move it but when it moves it does not work. the command works when you are in the car but it does not work when you are outside I think it has something to do with GetVehiclePos
pawn Код:
CMD:trunk(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new playerstate = GetPlayerState(playerid);
if(playerstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new string[256],name[MAX_PLAYER_NAME];
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
GetPlayerName(playerid,name,sizeof(name));
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if((boot)==-1)
{
boot = 0;
}
if((boot)==0)
{
format(string,sizeof(string),"%s press a button label trunk. The trunk of %s's vehicle opens",name,name);
for(new i; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
SendClientMessage(i,PURPLE,string);
}
}
SendClientMessage(playerid, -1, "You have open the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,true,objective);
}
else if((boot)==1)
{
format(string,sizeof(string),"%s press a button label trunk. The trunk of %s's vehicle closes",name,name);
for(new i; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
SendClientMessage(i,PURPLE,string);
}
}
SendClientMessage(playerid, -1, "You have closed the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,false,objective);
}
}
}
else
{
for(new count;count < MAX_VEHICLES;count++)
{
if(IsValidVehicle(count))
{
new Float:x,Float:y,Float:z;
GetVehiclePos(count,x,y,z);
y = y - 3;
if(IsPlayerInRangeOfPoint(playerid,1.5,x,y,z))
{
new vehicleid = count;
new engine,lights,alarm,doors,bonnet,boot,objective;
new string[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if((boot)==-1)
{
boot = 0;
}
if((boot)==0)
{
format(string,sizeof(string),"%s press down on the trunk. The trunk closes",name);
for(new i; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
SendClientMessage(i,PURPLE,string);
}
}
SendClientMessage(playerid, -1, "You have open the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,true,objective);
}
else if((boot)==1)
{
format(string,sizeof(string),"%s use his hand an pushes up the trunk. The trunk opens",name);
for(new i; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
SendClientMessage(i,PURPLE,string);
}
}
SendClientMessage(playerid, -1, "You have closed the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,false,objective);
}
return 1;
}
}
}
SendClientMessage(playerid, RED, "you have to be near the trunk of a vehicle or in a vehicle to open and close it");
}
return 1;
}
pawn Код:
CMD:hood(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new playerstate = GetPlayerState(playerid);
if(playerstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new string[256],name[MAX_PLAYER_NAME];
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
GetPlayerName(playerid,name,sizeof(name));
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if((bonnet)==-1)
{
bonnet = 0;
}
if((bonnet)==0)
{
format(string,sizeof(string),"%s flips the switch to open the hood. %s's car hood opens",name,name);
for(new i; i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,12.0,x,y,z))
{
SendClientMessage(i,PURPLE,string);
}
}
}
SendClientMessage(playerid, -1, "You have opened the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,true,boot,objective);
}
else if((bonnet)==1)
{
SendClientMessage(playerid, RED, "You have to close your hood from outside of your vehicle");
}
}
else
{
SendClientMessage(playerid,RED,"You have to be the driver inorder to open or you have to be outside of the vehicle inorder to close the hood");
}
}
else
{
for(new count;count < MAX_VEHICLES;count++)
{
if(IsValidVehicle(count))
{
new Float:x,Float:y,Float:z;
GetVehiclePos(count,x,y,z);
y = y + 2.5;
if(IsPlayerInRangeOfPoint(playerid,1.5,x,y,z))
{
new vehicleid = count;
new engine,lights,alarm,doors,bonnet,boot,objective;
new string[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if((bonnet)==1)
{
format(string,sizeof(string),"%s has pushed down on the trunk of his vehicle. The trunk closes",name);
for(new i;i < MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,12.0,x,y,z))
{
SendClientMessage(i,PURPLE,string);
}
}
}
SendClientMessage(playerid,-1,"You have closed the trunk");
SetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,false,boot,objective);
}
else
{
SendClientMessage(playerid, RED, "You have to be in the vehicle inorder to open the trunk");
}
return 1;
}
}
}
SendClientMessage(playerid,RED, "You have to be in the car to open the hood and you have to be outside the car to close it");
}
return 1;
}