How can I make the order/repair work just in front of a vehicle
#1

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;
}
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=486060

Код:
stock GetVehicleHood(vehicleid, &Float:x, &Float:y, &Float:z);
Reply
#3

How tu use?
Reply
#4

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(vehicleidXYZ);
    if(
IsPlayerInRangeOfPoint(playerid1.5XYZ))
    {
        
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000);
        
SetVehicleHealth(vehicleid1000.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 0vehicleid MAX_VEHICLESvehicleid++)
    {
        
GetVehicleHood(vehicleidXYZ);
        if(
IsPlayerInRangeOfPoint(playerid1.5XYZ))
        {
            
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000);
            
SetVehicleHealth(vehicleid1000.0);
            
RepairVehicle(vehicleid);
            break;
        }
        else 
SendClientMessage(playerid, -1"You're not near vehicle's hood.");
    }
    
    return 
1;

Reply
#5

Clear stock?
Reply
#6

Yes, use this code:

PHP код:

if(strcmp(cmd"/repair"true) == 0

    new  
    
Float:X
    
Float:Y
    
Float:Z
    
vehicleid GetNearestVehicle(); 


    
GetVehicleHood(vehicleidXYZ); 

    if(
IsPlayerInRangeOfPoint(playerid1.5XYZ)) 
    { 
        
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000); 
        
SetVehicleHealth(vehicleid1000.0); 
        
RepairVehicle(vehicleid); 
    } 
    else 
SendClientMessage(playerid, -1"You're not near vehicle's hood."); 
     
    return 
1

Reply
#7

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.
Reply
#8

Try changing the name of the Float Variables and change accordingly throughout the block.

EDIT:
Have you used the INCLUDES?
Reply
#9

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(vehicleidvXvYvZ); 
    if(
IsPlayerInRangeOfPoint(playerid1.5XYZ)) 
    { 
        
ApplyAnimation(playerid,"CAR""Fixn_Car_Loop",4.1,1,1,1,1,10000); 
        
SetVehicleHealth(vehicleid1000.0); 
        
RepairVehicle(vehicleid); 
    } 
    else 
SendClientMessage(playerid, -1"You're not near vehicle's hood."); 
     
    return 
1

Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)