SA-MP Forums Archive
Why isnt this working? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why isnt this working? (/showthread.php?tid=71333)



Why isnt this working? - Klutty - 31.03.2009

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


Re: Why isnt this working? - CAMERON_BANFIELD - 31.03.2009

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

use tht :P
Cameron


Re: Why isnt this working? - _TeRmiNaToR_ - 31.03.2009

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.


Re: Why isnt this working? - Dujma - 31.03.2009

This command will crash you if you are not in vehicle...


Re: Why isnt this working? - ICECOLDKILLAK8 - 31.03.2009

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;
}



Re: Why isnt this working? - Torekk - 31.03.2009

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


Re: Why isnt this working? - Dujma - 31.03.2009

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?


Re: Why isnt this working? - ICECOLDKILLAK8 - 31.03.2009

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