[HELP] GetPlayerClass? Under text command? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] GetPlayerClass? Under text command? (
/showthread.php?tid=124024)
[HELP] GetPlayerClass? Under text command? -
CrucixTM - 28.01.2010
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.
Re: [HELP] GetPlayerClass? Under text command? -
LuxurioN™ - 28.01.2010
Try this (I NOT TESTED):
---------------------
In top of your
Gm/Fs:
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;
}
}