How can I make the order/repair work just in front of a vehicle -
Jimmi - 09.06.2015
How can I make the order/repair work just in front of a vehicle
Код:
if(strcmp(cmd, "/repair", true) == 0)
{
if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14)
{
ApplyAnimation(playerid,"CAR", "Fixn_Car_Loop",4.1,1,1,1,1,10000);
new vehicleid = GetRepairCar(playerid);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
}
return 1;
}
Код:
stock GetRepairCar(playerid)
{
new Float:x, Float:y, Float:z;
new Float:dist, Float:closedist=9999, closeveh;
for(new i=1; i < MAX_VEHICLES; i++)
{
if(GetVehiclePos(i, x, y, z))
{
dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
if(dist < closedist)
{
closedist = dist;
closeveh = i;
}
}
}
return closeveh;
}
Re: How can I make the order/repair work just in front of a vehicle -
JaydenJason - 09.06.2015
https://sampforum.blast.hk/showthread.php?tid=486060
Код:
stock GetVehicleHood(vehicleid, &Float:x, &Float:y, &Float:z);
Re: How can I make the order/repair work just in front of a vehicle -
Jimmi - 10.06.2015
How tu use?
Re: How can I make the order/repair work just in front of a vehicle -
DarkLouis - 10.06.2015
Example code to detect if player is near hood and usage.
PHP код:
if(strcmp(cmd, "/repair", true) == 0)
{
new
Float:X,
Float:Y,
Float:Z,
vehicleid = Function;
GetVehicleHood(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z))
{
ApplyAnimation(playerid,"CAR", "Fixn_Car_Loop",4.1,1,1,1,1,10000);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
}
else SendClientMessage(playerid, -1, "You're not near vehicle's hood.");
return 1;
}
or
PHP код:
if(strcmp(cmd, "/repair", true) == 0)
{
new
Float:X,
Float:Y,
Float:Z;
for(new vehicleid = 0; vehicleid < MAX_VEHICLES; vehicleid++)
{
GetVehicleHood(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z))
{
ApplyAnimation(playerid,"CAR", "Fixn_Car_Loop",4.1,1,1,1,1,10000);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
break;
}
else SendClientMessage(playerid, -1, "You're not near vehicle's hood.");
}
return 1;
}
Re: How can I make the order/repair work just in front of a vehicle -
Jimmi - 10.06.2015
Clear stock?
Re: How can I make the order/repair work just in front of a vehicle -
DarkLouis - 10.06.2015
Yes, use this code:
PHP код:
if(strcmp(cmd, "/repair", true) == 0)
{
new
Float:X,
Float:Y,
Float:Z,
vehicleid = GetNearestVehicle();
GetVehicleHood(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z))
{
ApplyAnimation(playerid,"CAR", "Fixn_Car_Loop",4.1,1,1,1,1,10000);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
}
else SendClientMessage(playerid, -1, "You're not near vehicle's hood.");
return 1;
}
Re: How can I make the order/repair work just in front of a vehicle -
Jimmi - 10.06.2015
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(55602) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(55603) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(55604) : warning 219: local variable "Z" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(55605) : error 017: undefined symbol "GetNearestVehicle"
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(5560

: error 017: undefined symbol "GetVehicleHood"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: How can I make the order/repair work just in front of a vehicle -
SpaceX - 10.06.2015
Try changing the name of the Float Variables and change accordingly throughout the block.
EDIT:
Have you used the INCLUDES?
Re: How can I make the order/repair work just in front of a vehicle -
DarkLouis - 10.06.2015
Jimmi you need this:
https://sampforum.blast.hk/showthread.php?tid=486060
and change Float:X, Float:Y, Float:Z with another name( ES. Float:vX )
PHP код:
if(strcmp(cmd, "/repair", true) == 0)
{
new
Float:vX,
Float:vY,
Float:vZ,
vehicleid = GetNearestVehicle();
GetVehicleHood(vehicleid, vX, vY, vZ);
if(IsPlayerInRangeOfPoint(playerid, 1.5, X, Y, Z))
{
ApplyAnimation(playerid,"CAR", "Fixn_Car_Loop",4.1,1,1,1,1,10000);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
}
else SendClientMessage(playerid, -1, "You're not near vehicle's hood.");
return 1;
}
Re: How can I make the order/repair work just in front of a vehicle -
Jimmi - 10.06.2015
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "engine" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "lights" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "alarm" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "doors" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "bonnet" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "boot" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\pawno\include\EVF.inc(324) : warning 219: local variable "objective" shadows a variable at a preceding level
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(64) : error 021: symbol already defined: "IsValidVehicle"
C:\Users\Jimmi\Desktop\93.119.25.182-7777\gamemodes\RunStrike.pwn(55606) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.