Why isnt this working?
#1

pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
   new vehicleid = GetPlayerVehicleID(playerid);
   SetVehicleHealth(vehicleid,1000.0);
   }
Why isnt this working..?

It says "Unknown Command" In game..
Reply
#2

if(strcmp(cmdtext,"/fix",true)==0)
{
SendClientMessage(playerid, COLOR_RED, "Car Fixed");
SetVehicleHealth(GetPlayerVehicleID(playerid),1000 .0);
return 1;
}

use tht :P
Cameron
Reply
#3

Quote:
Originally Posted by Klutty
pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
   new vehicleid = GetPlayerVehicleID(playerid);
   SetVehicleHealth(vehicleid,1000.0);
   }
Why isnt this working..?

It says "Unknown Command" In game..
You must adding "return true;" in under your command.

pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
   if(IsPlayerInAnyVehicle(playerid))
   {
      new vehicleid = GetPlayerVehicleID(playerid);
      SetVehicleHealth(vehicleid,1000.0);
   }
   else { return 0; }

   return true; // true/false = 1/0
}
@ dujma: Fixed.
Reply
#4

This command will crash you if you are not in vehicle...
Reply
#5

Dont return 0, Try this
pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, color, "You are not in a Vehicle");
   new vehicleid = GetPlayerVehicleID(playerid);
   SetVehicleHealth(vehicleid,1000);
   return 1;
}
Reply
#6

pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, color, "You are not in a Vehicle");
    SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
    return 1;
}
Simple and it works fine. :P
Reply
#7

Quote:
Originally Posted by Torekk
pawn Код:
if (strcmp("/fix", cmdtext, true) == 0)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, color, "You are not in a Vehicle");
    SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
    return 1;
}
Simple and it works fine. :P
And what is the difference between your and JeNkStAX's code?
Reply
#8

I used the first post as a template so i kept in the vehicle id variable,
Instead of storing the vehicle id to a variable he used it in the function
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)