Problem in /heal
#1

hello when i type /heal in server nothing happens And there is no message
Please help:
this is my command:
Код:
CMD:heal(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(IsPlayerConnected(playerid))
	{
		new sendername[30],str[128],id,suma,Float:health;
		if(PlayerInfo[playerid][pMember] == 14 && IsAnAmbulance(GetPlayerVehicleID(playerid)) && GetPlayerVehicleSeat(playerid) == 0)
		if(PlayerInfo[playerid][pMember] == 18 && IsAnAmbulance(GetPlayerVehicleID(playerid)) && GetPlayerVehicleSeat(playerid) == 0)
		{
			if(sscanf(params, "ud",id,suma)) return SendClientMessage(playerid, COLOR_GREY, "Syntax:{FFFFFF} /heal [playerid/name] [amount]");
			if(suma < 1 || suma > 2000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 2000.");
			GetPlayerHealth(id, health);
			if(health <= 95)
			{
				if(GetPlayerCash(id) >= suma)
				{
					GivePlayerCash(id, -suma);
					GivePlayerCash(playerid, suma);
					Update(id, pCashx);
					Update(playerid, pCashx);
					SetPlayerHealthEx(id, 100.0);
					format(str, sizeof(str), "~h~healed~n~~g~+%s", FormatNumber(suma));
					GameTextForPlayer(playerid, str, 5000, 1);
					new varxx[256],are;
					format(varxx, sizeof(varxx), "SELECT * FROM `antifraudaraport` WHERE `pid1`='%d' AND `pid2`='%d'", PlayerInfo[playerid][pSQLID], PlayerInfo[id][pSQLID]);
					new Cache: ab = mysql_query(SQL, varxx);
					if(cache_get_row_count() > 0) are = 1;
					cache_delete(ab);
					if(are == 0)
					{
						mysql_format(SQL, varxx, sizeof(varxx), "UPDATE users SET Raport1 = Raport1+1 WHERE name = '%s'", PlayerInfo[playerid][pNormalName]);
						mysql_tquery(SQL,varxx,"","");
						mysql_format(SQL, varxx, sizeof(varxx), "INSERT INTO `antifraudaraport` (`pid1`,`pid2`,`time`) VALUES ('%d','%d','%d')", PlayerInfo[playerid][pSQLID], PlayerInfo[id][pSQLID], (gettime() + 900));
						mysql_tquery(SQL,varxx,"","");
					}
				}
				else return SendClientMessage(playerid, COLOR_GREY, "This player don't have enough money.");
			}
			else return SendClientMessage(playerid, COLOR_GREY, "This player have more than 95 hp.");
		}
		else
		{
			if(HealTimer[playerid] != 0) return SendClientMessage(playerid, COLOR_LIGHTGREEN3, "You need to wait 30 seconds before using /heal again.");
			if(InHouse[playerid] > 0)
			{
				if(HouseInfo[InHouse[playerid]][hHel] == 1)
				{
					SetPlayerHealthEx(playerid, 100.0);
					GetPlayerName(playerid, sendername, sizeof(sendername));
					format(str, sizeof(str),"* %s ate some food.",sendername);
					ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					HealTimer[playerid] = 30;
				}
				else return SendClientMessage(playerid, COLOR_GREY, "This house don't have a food upgrade.");
			}
			if(PlayerInfo[playerid][pMember] != 0 && IsInHQ(playerid))
			{
				SetPlayerHealthEx(playerid, 100.0);
				SetPlayerHealthEx(playerid, 100.0);
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(str, sizeof(str),"* %s ate some food.",sendername);
				ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				HealTimer[playerid] = 30;
			}
		}
	}
	return 1;
}
Reply
#2

Try this, I'm not sure if it's gonna work but it doesn't hurt to try right?

Код:
CMD:heal(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(IsPlayerConnected(playerid))
	{
		new sendername[30],str[128],id,suma,Float:health;
		if(PlayerInfo[playerid][pMember] == 18 && IsAnAmbulance(GetPlayerVehicleID(playerid)) && GetPlayerVehicleSeat(playerid) == 0 && PlayerInfo[playerid][pMember] == 14)
		{
			if(sscanf(params, "ud",id,suma)) return SendClientMessage(playerid, COLOR_GREY, "Syntax:{FFFFFF} /heal [playerid/name] [amount]");
			if(suma < 1 || suma > 2000) return SendClientMessage(playerid, COLOR_GREY, "Amount must be between 1 and 2000.");
			GetPlayerHealth(id, health);
			if(health <= 95)
			{
				if(GetPlayerCash(id) >= suma)
				{
					GivePlayerCash(id, -suma);
					GivePlayerCash(playerid, suma);
					Update(id, pCashx);
					Update(playerid, pCashx);
					SetPlayerHealthEx(id, 100.0);
					format(str, sizeof(str), "~h~healed~n~~g~+%s", FormatNumber(suma));
					GameTextForPlayer(playerid, str, 5000, 1);
					new varxx[256],are;
					format(varxx, sizeof(varxx), "SELECT * FROM `antifraudaraport` WHERE `pid1`='%d' AND `pid2`='%d'", PlayerInfo[playerid][pSQLID], PlayerInfo[id][pSQLID]);
					new Cache: ab = mysql_query(SQL, varxx);
					if(cache_get_row_count() > 0) are = 1;
					cache_delete(ab);
					if(are == 0)
					{
						mysql_format(SQL, varxx, sizeof(varxx), "UPDATE users SET Raport1 = Raport1+1 WHERE name = '%s'", PlayerInfo[playerid][pNormalName]);
						mysql_tquery(SQL,varxx,"","");
						mysql_format(SQL, varxx, sizeof(varxx), "INSERT INTO `antifraudaraport` (`pid1`,`pid2`,`time`) VALUES ('%d','%d','%d')", PlayerInfo[playerid][pSQLID], PlayerInfo[id][pSQLID], (gettime() + 900));
						mysql_tquery(SQL,varxx,"","");
					}
				}
				else return SendClientMessage(playerid, COLOR_GREY, "This player don't have enough money.");
			}
			else return SendClientMessage(playerid, COLOR_GREY, "This player have more than 95 hp.");
		}
		else
		{
			if(HealTimer[playerid] != 0) return SendClientMessage(playerid, COLOR_LIGHTGREEN3, "You need to wait 30 seconds before using /heal again.");
			if(InHouse[playerid] > 0)
			{
				if(HouseInfo[InHouse[playerid]][hHel] == 1)
				{
					SetPlayerHealthEx(playerid, 100.0);
					GetPlayerName(playerid, sendername, sizeof(sendername));
					format(str, sizeof(str),"* %s ate some food.",sendername);
					ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
					HealTimer[playerid] = 30;
				}
				else return SendClientMessage(playerid, COLOR_GREY, "This house don't have a food upgrade.");
			}
			if(PlayerInfo[playerid][pMember] != 0 && IsInHQ(playerid))
			{
				SetPlayerHealthEx(playerid, 100.0);
				SetPlayerHealthEx(playerid, 100.0);
				GetPlayerName(playerid, sendername, sizeof(sendername));
				format(str, sizeof(str),"* %s ate some food.",sendername);
				ProxDetector(30.0, playerid, str, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				HealTimer[playerid] = 30;
			}
		}
	}
	return 1;
}
Basically you made 2 if statements which can be easily placed in one. And as I said above I'm not sure if that's the problem here. Is this code placed in a filterscript or a GM, and what comes out after you type the command? Does the server say unknown command or what?
Reply
#3

You can't have pMember at 14 AND 18 at the same time so the above if-statement would never work.
Try this one instead to check if it's either 14 or 18, then check if he's in an ambulance and he's the driver:
Код:
if(((PlayerInfo[playerid][pMember] == 14) || (PlayerInfo[playerid][pMember] == 18)) && IsAnAmbulance(GetPlayerVehicleID(playerid)) && (GetPlayerVehicleSeat(playerid) == 0))
I also don't get the antifraude raport system in that command.
It doesn't block anything, except prevent making a second entry in the database.
Does that entry get removed somewhere else, which is inserted everytime someone uses the heal command?

What is it supposed to do?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)