What did I do wrong?
#1

Hmm...
Код HTML:
	if(price < 500 || price > 5000) return SendClientMessage(playerid, COLOR_ERROR, "Price number can't be below 500 or higher than 5000.");


Can someone tell me why this isn't working?
Reply
#2

Something wrong with your strtok or sscanf.

Looks like the zero is being read into price. Try using "/repair 501 501".

Show the complete command code.

You can do this too!

Код:
if(500 < price < 5000) 
{ 


}
else
{

}
Reply
#3

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Something wrong with your strtok or sscanf.

Looks like the zero is being read into price. Try using "/repair 501 501".

Show the complete command code.

You can do this too!

Код:
if(500 < price < 5000) 
{ 


}
else
{

}
This is the whole command.

Код HTML:
CMD:repair(playerid, params[])
{
	new string[256], playerb, price;
   	if(!IsPlayerLogged(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(sscanf(params, "us[64]", playerb, price)) return SendClientMessageEx(playerid, COLOR_WHITE, "[Usage]: /repair [playerid] [price]");
	if(PlayerInfo[playerid][pMoney] < 500) return SendClientMessage(playerid, COLOR_ERROR, "You must have at least $500 on you to repair a car.");
	if(PlayerInfo[playerid][pJob] != JOB_MECHANIC) return SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
	if(playerid == playerb)
	{
			if(sscanf(params, "us[64]", playerb, price)) return SendClientMessageEx(playerid, COLOR_WHITE, "[Usage]: /repair [playerid] [price]");
			if(PlayerInfo[playerid][pJob] != JOB_MECHANIC) return SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
   			if(!IsPlayerLogged(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
			if(price < 500 || price > 5000) return SendClientMessage(playerid, COLOR_ERROR, "Price number can't be below 500 or higher than 5000.");
			if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You must be inside a vehicle.");
			else if(gettime() - PlayerMuteInfo[playerid][RepairCool] < 0)
			{
				format(string, sizeof(string), "Please wait %i seconds before repairing again.", PlayerMuteInfo[playerid][RepairCool] - gettime());
		    	return SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
		   	}
			xGivePlayerMoney(playerid, -price);
			RepairVehicle(GetPlayerVehicleID(playerb));
			PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
			PlayerPlaySound(playerb,1133,0.0,0.0,0.0);
	}
	else if(gettime() - PlayerMuteInfo[playerid][RepairCool] < 0)
	{
		format(string, sizeof(string), "Please wait %i seconds before repairing again.", PlayerMuteInfo[playerid][RepairCool] - gettime());
    	return SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
   	}
	if(price < 500 || price > 5000) return SendClientMessage(playerid, COLOR_ERROR, "Price number can't be below 500 or higher than 5000.");
	if(!IsPlayerLogged(playerb)) return SendClientMessage(playerid, COLOR_ERROR, "Invalid player id.");
//	if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, COLOR_ERROR, "You must be at least level 2 to sell weapons.");
	if(IsPlayerNearby(playerid, playerb, 4)) return SendClientMessage(playerid, COLOR_ERROR, "You are too far away from that player.");
    SellRepairTo[playerid] = playerb;
	BuyRepairFrom[playerb] = playerid;
	BuyRepairPrice[playerb] = price;
	PlayerMuteInfo[playerid][RepairCool] = gettime() + 60;
	format(string, sizeof(string), " You have offered %s to repair their car for $%d.", GetPlayerNameEx(playerb), price);
	SendClientMessage(playerid, COLOR_GREY, string);
	format(string, sizeof(string), " %s has offered to repair your car for $%d. (/accept repair) (/cancel repair)", GetPlayerNameEx(playerid), price);
    SendClientMessage(playerb, COLOR_GREY, string);
	TextDrawShowForPlayer(playerb,RepairOffer);
	SetTimer("OfferedRepair", 4000, false);
	return 1;
}
Reply
#4

Change this:

PHP код:
if(sscanf(params"us[64]"playerbprice)) return SendClientMessageEx(playeridCOLOR_WHITE"[Usage]: /repair [playerid] [price]"); 
into this:

PHP код:
if(sscanf(params"ui"playerbprice)) return SendClientMessageEx(playeridCOLOR_WHITE"[Usage]: /repair [playerid] [price]"); 
Reply
#5

I've done that and am still having the same problem.
Reply
#6

Anyone know?
Reply
#7

Did you change it in both lines?
Reply
#8

Removed.
Reply
#9

Quote:
Originally Posted by Macronix
Посмотреть сообщение
Did you change it in both lines?
Yes, my bad. Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)