SA-MP Forums Archive
fix command - 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: fix command (/showthread.php?tid=67732)



fix command - thuron - 03.03.2009

hello,
i was trying to make a fix command for admins to fix their cars. i tryed to get one from internet, but they didn't work on my server, so i was going to make one myself.
now i got this and it wont work. and how can i make it say something if ur not in a vehicle?
here is the script:
Код:
{
	if (strcmp("/fix", cmdtext, true, 10) == 0)
	{
	  if(IsPlayerAdmin(playerid))
  				if(IsPlayerInAnyVehicle(playerid))
  				{
					SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
				}
				else
				{
				  SendClientMessage(playerid, COLOR_CRED, "SERVER: You are not an admin");
				}
	

		return 1;
	}
i hope you can help me.


thuron


Re: fix command - Rks25 - 03.03.2009

if (strcmp("/fix", cmdtext, true, 10) == 0)
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_CRED, "SERVER: You are not an admin");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_CRED, "SERVER: Not in car");
return 1;
}
SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
return 1;
}[/pawn]


Re: fix command - thuron - 03.03.2009

hmm, from now on its my only command in this script, but it wont work like this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])

{if (strcmp("/fix", cmdtext, true, 10) == 0)
{
  if(!IsPlayerAdmin(playerid))
  {
    SendClientMessage(playerid, COLOR_CRED, "SERVER: You are not an admin");
    return 1;
  }
  if(!IsPlayerInAnyVehicle(playerid))
  {
    SendClientMessage(playerid, COLOR_CRED, "SERVER: Not in car");
    return 1;
  }
  SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
  return 1;
}
	return 0;
}
anyone know what the problem is?


Re: fix command - Jefff - 03.03.2009

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp(cmdtext,"/fix", true) == 0)
	{
	  if(!IsPlayerAdmin(playerid))
	  {
	    SendClientMessage(playerid, COLOR_CRED, "SERVER: You are not an admin");
	    return 1;
	  }
	  if(!IsPlayerInAnyVehicle(playerid))
	  {
	    SendClientMessage(playerid, COLOR_CRED, "SERVER: Not in car");
	    return 1;
	  }
	  SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
	  return 1;
	}
	return 0;
}



Re: fix command - [LNL]Remulis - 03.03.2009

i have maken for you

Код:
	if(strcmp(cmdtext, "/fix", true) == 0) {
	SetVehicleHealth(GetPlayerVehicleID(playerid), 1000);
	SendClientMessage(playerid,COLOR_LIGHTBLUE,"*** Fixed!");
  return 1;
	}



Re: fix command - thuron - 03.03.2009

hmm, only says "You are not an admin"


Re: fix command - Jefff - 03.03.2009

Quote:
Originally Posted by thuron
hmm, only says "You are not an admin"
So log in?


Re: fix command - thuron - 03.03.2009

no, got it. you switched the message and the vehiclefix. so like this it works:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp(cmdtext,"/fix", true) == 0)
	{
	  if(!IsPlayerAdmin(playerid))
	  {
	  	SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
	    SendClientMessage(playerid, COLOR_CRED, "Your vehicle is fixed!");
	    return 1;
	  }
	  if(!IsPlayerInAnyVehicle(playerid))
	  {
	    SendClientMessage(playerid, COLOR_CRED, "SERVER: Not in car!");
	    return 1;
	  }
	  SendClientMessage(playerid, COLOR_CRED, "You are not an admin!");
	  return 1;
	}
	return 0;
}



Re: fix command - Rks25 - 03.03.2009

now it will do, if you are not an admin, it will fix car.
!IsPlayerAdmin means, if you are not an admin. And than you are letting him fix. weird
Jeff fixed it for you.


Re: fix command - MenaceX^ - 03.03.2009

pawn Код:
if(!strcmp(cmd,"/fix",true))
{
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR,"You are not an admin.");
  if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR,"You have to be inside a vehicle.");
  return SetVehicleHealth(GetPlayerVehicleID(playerid), 1000.0);
}