[HELP] GetPlayerClass? Under text command?
#1

Hey there, take a look at my code:

Код:
	if (strcmp("/swapg", cmdtext, true, 10) == 0)
	{
		new grenadeammo = GetPlayerAmmo(playerid);
		new grenweaponcheck = GetPlayerWeapon(playerid);
		if (classid == 4)
		{
			if (grenweaponcheck == 16)
			{
				GivePlayerWeapon(playerid, 18, grenadeammo);
				SendClientMessage(playerid, COLOR_YELLOW , "Swapped your current grenades for Molotov Cocktails.");
				return 1;
			}
			else if (grenweaponcheck == 18)
			{
				GivePlayerWeapon(playerid, 16, grenadeammo);
				SendClientMessage(playerid, COLOR_YELLOW , "Swapped your current grenades for Frag Grenades.");
				return 1;
			}
			else
			{
				SendClientMessage(playerid, COLOR_YELLOW , "Please equip your grenades or purchase new");
				SendClientMessage(playerid, COLOR_YELLOW , "ones with the /guns command to swap them.");
				return 1;
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED , "Command only available for Grenadiers.");
			return 1;
		}
I think most of it works, but I can't get the "if(classid == 4)" to work, since "public OnPlayerText(playerid, text[])" doesn't have that. How can I make it check the players class, I can't find a GetPlayerClass from the sidemenu(afaik).

Help a noob.
Reply
#2

Try this (I NOT TESTED):

---------------------

In top of your Gm/Fs:

pawn Код:
new pClass[MAX_PLAYERS];
In "OnPlayerRequestClass(playerid,classid)"

pawn Код:
pClass[playerid] = classid;
And, change your code to:

pawn Код:
if (strcmp("/swapg", cmdtext, true, 10) == 0)
{
new grenadeammo = GetPlayerAmmo(playerid);
new grenweaponcheck = GetPlayerWeapon(playerid);
if (pClass[playerid] == 2)
{
if (grenweaponcheck == 16)
{
GivePlayerWeapon(playerid, 18, grenadeammo);
SendClientMessage(playerid, COLOR_YELLOW , "Swapped your current grenades for Molotov Cocktails.");
return 1;
}
else if (grenweaponcheck == 18)
{
GivePlayerWeapon(playerid, 16, grenadeammo);
SendClientMessage(playerid, COLOR_YELLOW , "Swapped your current grenades for Frag Grenades.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW , "Please equip your grenades or purchase new");
SendClientMessage(playerid, COLOR_YELLOW , "ones with the /guns command to swap them.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_RED , "Command only available for Grenadiers.");
return 1;
}
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)