Insurance problem.
#1

Hello, I'm trying to fix my setinsurance commands that you see the name of the insurance in stead of the number

Errors I get
Код:
Gamemode.pwn(16399) : warning 219: local variable "insur" shadows a variable at a preceding level
Gamemode.pwn(16400) : error 033: array must be indexed (variable "-unknown-")
Gamemode.pwn(16397) : warning 203: symbol is never used: "insur"
Gamemode.pwn(23799) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Command:

Код:
CMD:setinsurance(playerid, params[])
{
 	if (PlayerInfo[playerid][pAdmin] >= 4)
	{
		new string[128], giveplayerid, insurance;
		if(sscanf(params, "ud", giveplayerid, insurance))
		{
			SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setinsurance [player] [insurance]");
			SendClientMessageEx(playerid, COLOR_RED, "NOTE: This command will be saved in server logs. Make sure you give ONLY insurance 3!");
			SendClientMessageEx(playerid, COLOR_ORANGE, "Available Insurances: 1 = [CountyGen], 2 = [All Saints]");
			SendClientMessageEx(playerid, COLOR_ORANGE, "Available Insurances: 3 = [Montgomery], 4 = [Fort Carson], 5 = [San Fiero]");
			SendClientMessageEx(playerid, COLOR_ORANGE, "Available Insurances: 6 = [Gold Room], 7 = [At Home], 8 = [BlueBerry], 9 = [Tierra Robada] 10 = [LAAS Base]");
			return 1;
		}

  		if(insurance >= 0 && insurance <= 10)
		{
			format(string, sizeof(string), " Your insurance has been changed to %d.", GetInsuranceName(giveplayerid));
			SendClientMessageEx(giveplayerid,COLOR_LIGHTBLUE,string);
			format(string, sizeof(string), " You have changed %s's insurance to %d.", GetPlayerNameEx(giveplayerid), GetInsuranceName(giveplayerid));
			SendClientMessageEx(playerid,COLOR_LIGHTBLUE,string);
			format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has set %s's insurance to %d.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetInsuranceName(giveplayerid));
			ABroadCast(COLOR_YELLOW, string, 4);
			PlayerInfo[giveplayerid][pInsurance] = GetInsuranceName(giveplayerid);
			Log("logs/insurance.log", string);
			return 1;
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
	}
	return 1;
}
Forward:

Код:
stock GetInsuranceName(insur)
{
	new insur[20];
	switch(insur)
	{
		case 1: insur = "County General";
		case 2: insur = "All Saints";
		case 3: insur = "Montgomery";
		case 4: insur = "Fort Carson";
		case 5: insur = "San Fierro";
		case 6: insur = "Club VIP";
		case 7: insur = "Home Care";
		case 9: insur = "El Quebrados";
		case 10: insur = "SAAS Base Hospital";
		case 11: insur = "Las Venturas";
		case 12: insur = "Special Room";
		case 13: insur = "LAAS Base";
		case 14: insur = "Bayside";
		default: insur = "None";
	}
	return insur;
}


How can I fix this ?
Reply
#2

Код:
stock GetInsuranceName(option)
{
	new insur[20];
	switch(option)
	{
		case 1: insur = "County General";
		case 2: insur = "All Saints";
		case 3: insur = "Montgomery";
		case 4: insur = "Fort Carson";
		case 5: insur = "San Fierro";
		case 6: insur = "Club VIP";
		case 7: insur = "Home Care";
		case 9: insur = "El Quebrados";
		case 10: insur = "SAAS Base Hospital";
		case 11: insur = "Las Venturas";
		case 12: insur = "Special Room";
		case 13: insur = "LAAS Base";
		case 14: insur = "Bayside";
		default: insur = "None";
	}
	return insur;
}
Reply
#3

Still got 1 error:

Код:
Gamemode.pwn(23799) : error 006: must be assigned to an array
Line 23799

Код:
			ABroadCast(COLOR_YELLOW, string, 4);
			PlayerInfo[giveplayerid][pInsurance] = GetInsuranceName(giveplayerid);
			Log("logs/insurance.log", string);
Reply
#4

Error has been fixed but, still when I set my insurance I get numbers in stead of the name:

Reply
#5

Use %s and not %d when showing strings in format.
Reply
#6

Ooh yes, forgot that...

But it doesn't work ether..
See screenshot I have set my insurance to 3

Reply
#7

I'm guessing your playerid is 0.

You're using GetInsuranceName on 'giveplayerid' (Which is 0 most likely, since you're testing it)
Replace giveplayerid with the actual insurance id (For example, Insurance[playerid])
Reply
#8

Like this:

Код:
if(insurance >= 0 && insurance <= 10)
		{
			format(string, sizeof(string), " Your insurance has been changed to %s.", GetInsuranceName(playerid));
			SendClientMessageEx(giveplayerid,COLOR_LIGHTBLUE,string);
			format(string, sizeof(string), " You have changed %s's insurance to %s.", GetPlayerNameEx(giveplayerid), GetInsuranceName(playerid));
			SendClientMessageEx(playerid,COLOR_LIGHTBLUE,string);
			format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has set %s's insurance to %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), GetInsuranceName(playerid));
			ABroadCast(COLOR_YELLOW, string, 4);
			PlayerInfo[giveplayerid][pInsurance] = insurance;
			Log("logs/insurance.log", string);
			return 1;
		}
	}
Isn't working...
Reply
#9

No, I said use the insurance id, and not the playerid.
Reply
#10

Sorry, I don't understand what you mean by that..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)