Help with GetPlayerState - 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)
+--- Thread: Help with GetPlayerState (
/showthread.php?tid=590765)
Help with GetPlayerState -
kartik - 03.10.2015
Код:
CMD:weapons(playerid)
{
//{250,300,1500,1000,1200,1300,1500,2000,2100,500,500,2100,2400,500,3000}
if(GetPlayerState(playerid)!=PLAYER_STATE_WASTED)
{
ShowPlayerDialog(playerid,D_WEAPONS,DIALOG_STYLE_TABLIST_HEADERS,"{45ff88}Buy a Weapon",
"Weapon\tPrice\tAmmo\n\
Brass Knuckles\t250\t1\n\
Knife\t300\t1\n\
Grenade\t1500\t15\n\
Molotov Cocktail\t1000\t20\n\
9mm\t1200\t700\n\
Silenced 9mm\t1300\t700\n\
Desert Eagle\t1500\t450\n\
Sawn-Off Shotgun\t2000\t200\n\
Combat Shotgun\t2100\t350\n\
Micro SMG(Uzi)\t500\t2000\n\
MP5\t500\t2000\n\
AK-47\t2100\t1500\n\
M4\t2400\t1700\n\
Tec9\t500\t2000\n\
Sniper Rifle\t3000\t345\n",
"Buy","Back");
}
else SendClientMessage(playerid,0xff5678,"You have not spawned yet");
return 1;
}
My problem is that the menu shows even at class selection when i do /weapons. Why is it doing so?
Re: Help with GetPlayerState -
Mister0 - 03.10.2015
Why don't you use getplayerhealth?
PHP код:
CMD:weapons(playerid)
{
//{250,300,1500,1000,1200,1300,1500,2000,2100,500,500,2100,2400,500,3000}
new Float:heal;
GetPlayerHealth (playerid, heal);
if (heal>0.5)
{
ShowPlayerDialog(playerid,D_WEAPONS,DIALOG_STYLE_TABLIST_HEADERS,"{45ff88}Buy a Weapon",
"Weapon\tPrice\tAmmo\n\
Brass Knuckles\t250\t1\n\
Knife\t300\t1\n\
Grenade\t1500\t15\n\
Molotov Cocktail\t1000\t20\n\
9mm\t1200\t700\n\
Silenced 9mm\t1300\t700\n\
Desert Eagle\t1500\t450\n\
Sawn-Off Shotgun\t2000\t200\n\
Combat Shotgun\t2100\t350\n\
Micro SMG(Uzi)\t500\t2000\n\
MP5\t500\t2000\n\
AK-47\t2100\t1500\n\
M4\t2400\t1700\n\
Tec9\t500\t2000\n\
Sniper Rifle\t3000\t345\n",
"Buy","Back");
}
else SendClientMessage(playerid,0xff5678,"You have not spawned yet");
return 1;
}
Re: Help with GetPlayerState -
kartik - 04.10.2015
Thanks, that one works. Any idea why GetPlayerState is causing problems?
Re: Help with GetPlayerState -
xVIP3Rx - 04.10.2015
Debug to find out..Check thier current state when you type it.
Also try this
pawn Код:
CMD:weapons(playerid)
{
//{250,300,1500,1000,1200,1300,1500,2000,2100,500,500,2100,2400,500,3000}
if(GetPlayerState(playerid) != PLAYER_STATE_SPAWNED) return SendClientMessage(playerid,0xff5678,"You have not spawned yet");
ShowPlayerDialog(playerid,D_WEAPONS,DIALOG_STYLE_TABLIST_HEADERS,"{45ff88}Buy a Weapon",
"Weapon\tPrice\tAmmo\n\
Brass Knuckles\t250\t1\n\
Knife\t300\t1\n\
Grenade\t1500\t15\n\
Molotov Cocktail\t1000\t20\n\
9mm\t1200\t700\n\
Silenced 9mm\t1300\t700\n\
Desert Eagle\t1500\t450\n\
Sawn-Off Shotgun\t2000\t200\n\
Combat Shotgun\t2100\t350\n\
Micro SMG(Uzi)\t500\t2000\n\
MP5\t500\t2000\n\
AK-47\t2100\t1500\n\
M4\t2400\t1700\n\
Tec9\t500\t2000\n\
Sniper Rifle\t3000\t345\n",
"Buy","Back");
return 1;
}