i need help for /tow command
#1

Hy all.
I have made a code /tow for mechanic job but i have a problem and i don't know how to fix it.
i don't want to tow the car if the car is at the original place (car spawn point)..i want to give me a message like "the car is not in need of a tow"

can anyone help me with this?
i think is something with GetVehiclePos.....but i dono how to use it.

pawn Код:
if(strcmp(cmd,"/tow",true)==0)
    {
      if(IsPlayerConnected(playerid))
        {
          if(PlayerInfo[playerid][pJob] == 7)
          {
            if(IsPlayerInAnyVehicle(playerid))
            {
                if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
                {
                  if(GetPlayerState(playerid)==2)
                  {
                            new Float:pX,Float:pY,Float:pZ;
                            GetPlayerPos(playerid,pX,pY,pZ);
                            new Float:vX,Float:vY,Float:vZ;
                            new Found=0;
                            new vid=0;
                            while((vid<MAX_VEHICLES)&&(!Found))
                            {
                                vid++;
                                GetVehiclePos(vid,vX,vY,vZ);
                                if ((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
                                {
                                Found=1;
                                if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                                {
                                    DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                                }
                                else
                                {
                              AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
                                SendClientMessage(playerid, COLOR_GRAD2, "Tow the car to the Checkpoint shown on the minimap.");
                                  CP[playerid] = 22;
                    SetPlayerCheckpoint(playerid,2185.7034,-1992.6033,13.4245,6.0);
                                    }
                                }
                        }
                            if(!Found)
                            {
                                SendClientMessage(playerid,0xFFFF00AA,"There is no car in range.");
                            }
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GRAD2, "You need to be the driver!");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "You need to be in a Tow truck to use this!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "You need to be in a vehicle to do this!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_GRAD2,"You need to be a Mechanic to use this!");
                return 1;
            }
        }
        return 1;
    }
pawn Код:
else if(CP[playerid]==22)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
     PlayerInfo[playerid][pMechSkill] ++;
       if(PlayerInfo[playerid][pMechSkill] == 50)
       {
         SendClientMessage(playerid, COLOR_YELLOW, "* Your Car Mechanic Skill is now Level 2, you will earn more Money and quicker Reload Time.");
     }
       else if(PlayerInfo[playerid][pMechSkill] == 100)
       {
         SendClientMessage(playerid, COLOR_YELLOW, "* Your Car Mechanic Skill is now Level 3, you will earn more Money and quicker Reload Time.");
     }
       else if(PlayerInfo[playerid][pMechSkill] == 200)
       {
         SendClientMessage(playerid, COLOR_YELLOW, "* Your Car Mechanic Skill is now Level 4, you will earn more Money and quicker Reload Time.");
     }
       else if(PlayerInfo[playerid][pMechSkill] == 400)
       {
         SendClientMessage(playerid, COLOR_YELLOW, "* Your Car Mechanic Skill is now Level 5, you will earn more Money and quicker Reload Time.");
     }
       new level = PlayerInfo[playerid][pMechSkill];
       if(level >= 0 && level <= 50)
       {
       new rand = random(sizeof(SELLCAR1));
       format(string, sizeof(string), "Car Towed Successfully for %d$.", TOWCAR1[rand]);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
         GivePlayerMoney(playerid, SELLCAR1[rand]);
       }
       else if(level >= 51 && level <= 100)
       {
       new rand = random(sizeof(SELLCAR2));
       format(string, sizeof(string), "Car Towed Successfully for %d$.", TOWCAR2[rand]);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
       GivePlayerMoney(playerid, SELLCAR2[rand]);
       }
       else if(level >= 101 && level <= 200)
       {
       new rand = random(sizeof(SELLCAR3));
       format(string, sizeof(string), "Car Towed Successfully for %d$.", TOWCAR3[rand]);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
         GivePlayerMoney(playerid, SELLCAR3[rand]);
       }
       else if(level >= 201 && level <= 400)
       {
       new rand = random(sizeof(SELLCAR4));
       format(string, sizeof(string), "Car Towed Successfully for %d$.", TOWCAR4[rand]);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
         GivePlayerMoney(playerid, SELLCAR4[rand]);
       }
       else if(level >= 401)
       {
       new money = 6000;
       format(string, sizeof(string), "Car Towed Successfully for %d$.", money);
         SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
         GivePlayerMoney(playerid, money);
       }
       new carid = GetPlayerVehicleID(playerid);
       GameTextForPlayer(playerid, "~y~Car Towed", 2500, 1);
       CP[playerid] = 0;
     DisablePlayerCheckpoint(playerid);
     DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
     SetVehicleToRespawn(GetVehicleTrailer(carid));
      }
    else
      {
     GameTextForPlayer(playerid, "Not in a car", 5000, 1);
      }
  }
Reply
#2

OnVehicleSpawn save the coords into an array, then check them when you tow.
Reply
#3

Quote:
Originally Posted by Mikep
OnVehicleSpawn save the coords into an array, then check them when you tow.
how can i use that?
where to put that "OnVehicleSpawn"?

show me...

thx
Reply
#4

My best bet would be in a .pwn file.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)