Menu problem -
joe_stoner - 18.01.2010
Alright I read the create a simple menu tutorial on SA-MP Wiki, I have a menu for when a cop type's /duty the menu opens for them and a list of stuff to choose from, when they choose something though, you can't open then menu again if you type /duty, nothing happens.
Код:
if(CurrentMenu == copduty)
{
switch(row)
{
case 0: //Patrol
{
SetPlayerArmour(playerid,100);
SetPlayerHealth(playerid,100);
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,41,1000);
GivePlayerWeapon(playerid,3,1);
SetPlayerSkin(playerid,280);
CopOnDuty[playerid] = 1;
TogglePlayerControllable(playerid,1);
format(string, sizeof(string), "%s is now an on duty patrol officer.",GetPlayerNameEx(playerid));
SendFactionTypeMessage(1, COLOR_LSPD, string);
}
case 1: //S.W.A.T
{
SetPlayerArmour(playerid,100);
SetPlayerHealth(playerid,100);
GivePlayerWeapon(playerid,17,50);
GivePlayerWeapon(playerid,27,100);
GivePlayerWeapon(playerid,31,200);
SetPlayerSkin(playerid,285);
CopOnDuty[playerid] = 1;
TogglePlayerControllable(playerid,1);
format(string, sizeof(string), "%s is now an on duty s.w.a.t officer.",GetPlayerNameEx(playerid));
SendFactionTypeMessage(1, COLOR_LSPD, string);
}
case 2: //Marksman
{
SetPlayerArmour(playerid,100);
SetPlayerHealth(playerid,100);
GivePlayerWeapon(playerid,34,50);
GivePlayerWeapon(playerid,23,50);
SetPlayerSkin(playerid,285);
CopOnDuty[playerid] = 1;
TogglePlayerControllable(playerid,1);
format(string, sizeof(string), "%s is now an on duty marksman officer.",GetPlayerNameEx(playerid));
SendFactionTypeMessage(1, COLOR_LSPD, string);
}
case 3: //Undercover
{
SetPlayerArmour(playerid,100);
SetPlayerHealth(playerid,100);
GivePlayerWeapon(playerid,24,100);
GivePlayerWeapon(playerid,43,50);
SetPlayerSkin(playerid,29);
CopOnDuty[playerid] = 1;
TogglePlayerControllable(playerid,1);
format(string, sizeof(string), "%s is now an on duty undercover officer.",GetPlayerNameEx(playerid));
SendFactionTypeMessage(1, COLOR_LSPD, string);
}
case 4: //Off Duty
{
SetPlayerHealth(playerid,100);
ResetPlayerWeapons(playerid);
CopOnDuty[playerid] = 0;
TogglePlayerControllable(playerid,1);
SetPlayerToFactionSkin(playerid);
SetPlayerToFactionColor(playerid);
format(string, sizeof(string), "%s is now an off duty officer.",GetPlayerNameEx(playerid));
SendFactionTypeMessage(1, COLOR_LSPD, string);
}
}
}
return 1;
}
Re: Menu problem -
Joe Staff - 18.01.2010
You're gonna have to show us the part that brings up the menu.
Re: Menu problem -
joe_stoner - 18.01.2010
Alright here it is, This is Carlito's by the way.
Код:
if(strcmp(cmd, "/duty", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
{
if (PlayerToPoint(5.0, playerid,PoliceDutyPosition[X],PoliceDutyPosition[Y],PoliceDutyPosition[Z]))
{
if(GetPlayerVirtualWorld(playerid) == PoliceDutyPosition[World])
{
if(CopOnDuty[playerid] == 0)
{
ShowMenuForPlayer(copduty,playerid);
return 1;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not at the duty position!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Invalid Faction/Type.");
return 1;
}
}
return 1;
}
Re: Menu problem -
Joe Staff - 18.01.2010
Here's your problem,
pawn Код:
if(CopOnDuty[playerid] == 0)
but in your menu you have that being set to 1. So that conditional won't work.
Re: Menu problem -
joe_stoner - 18.01.2010
Oh.. So I should take that out of the menu and make it so that when you type /duty you automatically go on it and put something like else and make it 0?
Edit: Nvm I'm just going to take that line out of /duty
Re: Menu problem -
Joe Staff - 18.01.2010
No, just remove this from your command
pawn Код:
if(CopOnDuty[playerid] == 0)//<--
{//<--
ShowMenuForPlayer(copduty,playerid);
return 1;
}//<--
Re: Menu problem -
joe_stoner - 18.01.2010
Ok I did that but, when you type /duty it still won't open back up.
Re: Menu problem -
Calgon - 18.01.2010
Sorry for interjecting with a slightly off-topic comment, but you'd have better luck with dialogs. A lot easier to create and they function better IMO. I created a tutorial on the wiki, not too long ago explaining how they work.
Re: Menu problem -
Joe Staff - 18.01.2010
pawn Код:
if(strcmp(cmd, "/duty", true) == 0)
{
if(!(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1))return SendClientMessage(playerid, COLOR_GREY, "Invalid Faction/Type.");
if (!IsPlayerInRangeOfPoint(playerid,5.0,PoliceDutyPosition[X],PoliceDutyPosition[Y],PoliceDutyPosition[Z]))return SendClientMessage(playerid, COLOR_GREY, "You are not at the duty position!");
if(GetPlayerVirtualWorld(playerid) != PoliceDutyPosition[World])return SendClientMessage(playerid, COLOR_GREY, "You are not at the duty position!");
ShowMenuForPlayer(copduty,playerid);
return 1;
}
Re: Menu problem -
joe_stoner - 18.01.2010
:P Sorry but I put yours in and it still didn't work you can type /duty once for the menu you click a menu item and then you can't type /duty anymore to bring up the menu