Insurance bugged
#1

/buyinsurance bugged. it didn't set the player insurance to hospital 1 nor hospital 2 but /setinsurance is working well help me here please?

Код:
CMD:setinsurance(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
 		if(PlayerInfo[playerid][pAdminDuty] != 1 && PlayerInfo[playerid][pAdmin] < 6)
	    {
	        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
			return 1;
	    }
		new string[128], giveplayerid, insurance;
		if(sscanf(params, "ud", giveplayerid, insurance))
		{
			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setinsurance [playerid/partofname] [insurance]");
			SendClientMessage(playerid, COLOR_GREY, "Available Insurances: 0, 1, 2");
			return 1;
		}

		if(insurance >= 0 && insurance <= 2)
		{
			format(string, sizeof(string), " Your insurance has been changed to %d.", insurance);
			SendClientMessage(giveplayerid,COLOR_YELLOW,string);
			format(string, sizeof(string), " You have changed %s's insurance to %d.", GetPlayerNameEx(giveplayerid), insurance);
			SendClientMessage(playerid,COLOR_YELLOW,string);
			PlayerInfo[giveplayerid][pInsurance] = insurance;

			mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET insurance = %i WHERE uid = %i",PlayerInfo[playerid][pInsurance], PlayerInfo[playerid][pID]);
   			mysql_tquery(connectionID, queryBuffer);

			return 1;
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_GREY, "You're not authorized to use that command!");
	}
	return 1;
}

CMD:buyinsurance(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid,3.0,-28.113214, 152.052932, 999.062377) && PlayerInfo[playerid][pWorld] == 2)
	{
        if(PlayerInfo[playerid][pCash] >= 400)
		{
            if(PlayerInfo[playerid][pInsurance] == 1)
			{
                GivePlayerCash(playerid, -400);
                PlayerInfo[playerid][pInsurance] = 1;
                SendClientMessage(playerid, COLOR_WHITE, " Insurance purchased, you paid $150 + a one-time transfer fee of $250, you will now be healed at All Saints Hospital for $150.");

                mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET insurance = %i WHERE uid = %i", PlayerInfo[playerid][pInsurance], PlayerInfo[playerid][pID]);
                mysql_tquery(connectionID, queryBuffer);
                return 1;
            }
            else
			{
                SendClientMessage(playerid, COLOR_GREY, "You already have insurance at All Saints Hospital!");
            }
        }
        else
		{
            SendClientMessage(playerid, COLOR_GREY, "You don't have enough money for this insurance!");
        }
    }
    else if(IsPlayerInRangeOfPoint(playerid,3.0,-28.113214, 152.052932, 999.062377) && PlayerInfo[playerid][pWorld] == 1)
	{
        if(PlayerInfo[playerid][pCash] >= 400)
		{
            if(PlayerInfo[playerid][pInsurance] == 2)
			{
                GivePlayerCash(playerid, -400);
                PlayerInfo[playerid][pInsurance] = 2;
                SendClientMessage(playerid, COLOR_WHITE, " Insurance purchased, you paid $150 + a one-time transfer fee of $250, you will now be healed at County General Hospital for $150.");

                mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET insurance = %i WHERE uid = %i",PlayerInfo[playerid][pInsurance], PlayerInfo[playerid][pID]);
                mysql_tquery(connectionID, queryBuffer);
                return 1;
            }
            else
			{
                SendClientMessage(playerid, COLOR_GREY, "You already have insurance at County General Hospital!");
            }
        }
        else
		{
            SendClientMessage(playerid, COLOR_GREY, "You don't have enough money for this insurance!");
        }
    }
    return 1;
}
Reply
#2

You made a condition to check if the player already have an insurance, that would set him an insurance - thats an issue.
ex. change:
Код:
if(PlayerInfo[playerid][pInsurance] == 2)
to:
Код:
if(PlayerInfo[playerid][pInsurance] != 2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)