fix command
#1

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

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]
Reply
#3

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?
Reply
#4

Код:
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;
}
Reply
#5

i have maken for you

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

hmm, only says "You are not an admin"
Reply
#7

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

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)