Wierd bug.
#1

I have this command:

Code:
CMD:tradecar(playerid, params[])
{	
	new id, dif, Float:x, Float:y, Float:z, string[256];
	if(sscanf(params, "r", id)) return SCM(playerid, COLOR_GRAD2, "Usage: {FFFFFF}/tradecar [playerid] + [difference]");
	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, "You must be in your vehicle to use this command.");
	if(!IsPlayerInAnyVehicle(id)) return SCM(playerid, -1, "That user must be in his vehicle.");
	if(dif > playerVariables[playerid][pMoney]) return SCM(playerid, -1, "You don't have that much money.");
	new cf[128];
	format(cf, sizeof(cf), "You must wait %d seconds.", Cooldown[playerid]);
	if(Cooldown[playerid] > 0) return SCM(playerid, -1, cf);
	new hiscar = GetPlayerVehicleID(id);
	new mycar = GetPlayerVehicleID(playerid);
	new hid = GetVID(hiscar);
	new mid = GetVID(mycar);
	GetPlayerPos(id, x, y, z);
	if(vehStat[hid][vOwnerID] != playerVariables[id][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by that user.");
	if(vehStat[mid][vOwnerID] != playerVariables[playerid][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by you.");
	if(sscanf(params, "rd", id, dif))
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d + $%s difference from him.", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2], NumberFormat(dif));
			SCM(id, COLOR_YELLOW, string);	
			HisMoney[playerid] = dif;
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehicle for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent 2.");
			TradeType[playerid] = 2;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	else
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehiclel for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent.");
			TradeType[playerid] = 1;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	return 1;
}
Whenever I use /tradecar [playerid] [difference]
this part gets called. This part should be called when you use /tradecar [playerid]. Not /tradecar [playerid] [difference]
Code:
else
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehiclel for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent.");
			TradeType[playerid] = 1;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
Instead of this part.
Code:
if(sscanf(params, "rd", id, dif))
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);	
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d + $%s difference from him.", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2], NumberFormat(dif));
			SCM(id, COLOR_YELLOW, string);	
			HisMoney[playerid] = dif;
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehicle for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent 2.");
			TradeType[playerid] = 2;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
Why is this happaning?
Reply
#2

Try this, (Not sure about it!)
Code:
CMD:tradecar(playerid, params[])
{
	new id, dif, Float:x, Float:y, Float:z, string[256];
	if(sscanf(params, "rr",id,dif)) return SCM(playerid, COLOR_GRAD2, "Usage: {FFFFFF}/tradecar [playerid] + [difference]");
	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, "You must be in your vehicle to use this command.");
	if(!IsPlayerInAnyVehicle(id)) return SCM(playerid, -1, "That user must be in his vehicle.");
	if(dif > playerVariables[playerid][pMoney]) return SCM(playerid, -1, "You don't have that much money.");
	new cf[128];
	format(cf, sizeof(cf), "You must wait %d seconds.", Cooldown[playerid]);
	if(Cooldown[playerid] > 0) return SCM(playerid, -1, cf);
	new hiscar = GetPlayerVehicleID(id);
	new mycar = GetPlayerVehicleID(playerid);
	new hid = GetVID(hiscar);
	new mid = GetVID(mycar);
	GetPlayerPos(id, x, y, z);
	if(vehStat[hid][vOwnerID] != playerVariables[id][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by that user.");
	if(vehStat[mid][vOwnerID] != playerVariables[playerid][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by you.");
	if(!isnull(dif))
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d + $%s difference from him.", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2], NumberFormat(dif));
			SCM(id, COLOR_YELLOW, string);
			HisMoney[playerid] = dif;
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehicle for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent 2.");
			TradeType[playerid] = 2;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	else
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehiclel for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent.");
			TradeType[playerid] = 1;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	return 1;
}
Reply
#3

Quote:
Originally Posted by ColdGamePlay
View Post
Try this, (Not sure about it!)
Code:
CMD:tradecar(playerid, params[])
{
	new id, dif, Float:x, Float:y, Float:z, string[256];
	if(sscanf(params, "rr",id,dif)) return SCM(playerid, COLOR_GRAD2, "Usage: {FFFFFF}/tradecar [playerid] + [difference]");
	if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid, -1, "You must be in your vehicle to use this command.");
	if(!IsPlayerInAnyVehicle(id)) return SCM(playerid, -1, "That user must be in his vehicle.");
	if(dif > playerVariables[playerid][pMoney]) return SCM(playerid, -1, "You don't have that much money.");
	new cf[128];
	format(cf, sizeof(cf), "You must wait %d seconds.", Cooldown[playerid]);
	if(Cooldown[playerid] > 0) return SCM(playerid, -1, cf);
	new hiscar = GetPlayerVehicleID(id);
	new mycar = GetPlayerVehicleID(playerid);
	new hid = GetVID(hiscar);
	new mid = GetVID(mycar);
	GetPlayerPos(id, x, y, z);
	if(vehStat[hid][vOwnerID] != playerVariables[id][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by that user.");
	if(vehStat[mid][vOwnerID] != playerVariables[playerid][pInternalID]) return SCM(playerid, -1, "That vehicle is not owned by you.");
	if(!isnull(dif))
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d + $%s difference from him.", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2], NumberFormat(dif));
			SCM(id, COLOR_YELLOW, string);
			HisMoney[playerid] = dif;
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehicle for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent 2.");
			TradeType[playerid] = 2;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	else
	{
		if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
		{
			MyTrade[playerid] = mycar;
			HisTrade[id] = hiscar;
			format(string, sizeof(string), "New Offer From %s", GetName(playerid));
			SCM(id, 0xFF99311EFF, string);
			format(string, sizeof(string), "%s want's to trade his: %s [%d] | %d days | %d KM | colors: %d - %d", GetName(playerid), VehicleNames[GetVehicleModel(mycar) - 400], vehStat[mid][vID], vehStat[mid][vDays], vehStat[mid][vKM], vehStat[mid][vColor1], vehStat[mid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "For your: %s [%d] | %d days | %d KM | colors: %d - %d", VehicleNames[GetVehicleModel(hiscar) - 400], vehStat[hid][vID], vehStat[hid][vDays], vehStat[hid][vKM], vehStat[hid][vColor1], vehStat[hid][vColor2]);
			SCM(id, COLOR_YELLOW, string);
			format(string, sizeof(string), "Use /accept tradecar %d to trade your vehiclel for %s's vehicle.", playerid, playerVariables[playerid][pNormalName]);
			SCM(id, COLOR_YELLOW, string);
			SCM(playerid, -1, "Offer has been sent.");
			TradeType[playerid] = 1;
		}
		else return SCM(playerid, -1, "You're not near that player.");
	}
	return 1;
}
Nope, doesn't work.
Reply
#4

why you are using r for userid?

PHP Code:
if(sscanf(params"u"id)) return SCM(playeridCOLOR_GRAD2"Usage: {FFFFFF}/tradecar [playerid] + [difference]"); 
for user you must use u read about sscanf here
https://sampwiki.blast.hk/wiki/Sscanf_code
Reply
#5

Creating multiple threads about the same issue and ignoring all the posts in the previous threads is not cool. He explained very well why this happens: http://forum.sa-mp.com/showpost.php?...41&postcount=4

Quote:
Originally Posted by IceBilizard
View Post
why you are using r for userid?

PHP Code:
if(sscanf(params"u"id)) return SCM(playeridCOLOR_GRAD2"Usage: {FFFFFF}/tradecar [playerid] + [difference]"); 
for user you must use u read about sscanf here
https://sampwiki.blast.hk/wiki/Sscanf_code
"r" specifier is only for players whereas "u" is for both players and NPCs. For more information, refer to this thread: https://sampforum.blast.hk/showthread.php?tid=602923
as that wiki link is outdated.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)