hier falls es immernochnet klappt ein waffen fs mit menu is au einfacher
#include <a_samp>
#include <float>
#define red 0xFF0000AA
#define yellow 0xFFFF00AA
new Menu:FWeapons;
new Menu:FPistols;
new Menu:FMicro_SMGs;
new Menu:FShotguns;
new Menu:FArmour;
new Menu:FSMG;
new Menu:FRifles;
new Menu:FAssault;
new Float:health;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" [FS] Waffenmenu");
print("--------------------------------------\n");
FWeapons = CreateMenu("Weapons",1,20,120,150,40);
AddMenuItem(FWeapons,0,"Pistols");
AddMenuItem(FWeapons,0,"Micro SMGs");
AddMenuItem(FWeapons,0,"Shotguns");
AddMenuItem(FWeapons,0,"Armour");
AddMenuItem(FWeapons,0,"SMG");
AddMenuItem(FWeapons,0,"Rifles");
AddMenuItem(FWeapons,0,"Assault");
FPistols = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FPistols,0,"Weapons");
AddMenuItem(FPistols,0,"9mm");
AddMenuItem(FPistols,0,"Silenced 9mm");
AddMenuItem(FPistols,0,"Desert Eagle");
AddMenuItem(FPistols,0,"<back>");
FMicro_SMGs = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FMicro_SMGs,0,"Weapons");
AddMenuItem(FMicro_SMGs,0,"Tec9");
AddMenuItem(FMicro_SMGs,0,"Micro SMG");
AddMenuItem(FMicro_SMGs,0,"<back>");
FShotguns = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FShotguns,0,"Weapons");
AddMenuItem(FShotguns,0,"Shotgun");
AddMenuItem(FShotguns,0,"Sawnoff Shotgun");
AddMenuItem(FShotguns,0,"<back>");
FArmour = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FArmour,0,"Weapons");
AddMenuItem(FArmour,0,"Body Armour");
AddMenuItem(FArmour,0,"<back>");
FSMG = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FSMG,0,"Weapons");
AddMenuItem(FSMG,0,"SMG");
AddMenuItem(FSMG,0,"<back>");
FRifles = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FRifles,0,"Weapons");
AddMenuItem(FRifles,0,"Rifle");
AddMenuItem(FRifles,0,"Sniper Rifle");
AddMenuItem(FRifles,0,"<back>");
FAssault = CreateMenu("Weapons",1,20,120,150,40);
SetMenuColumnHeader(FAssault,0,"Weapons");
AddMenuItem(FAssault,0,"AK47");
AddMenuItem(FAssault,0,"M4");
AddMenuItem(FAssault,0,"<back>");
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/waffen", true) == 0)
{
GetPlayerHealth(playerid, health);
GetPlayerHealth(playerid, Float:health);
TogglePlayerControllable(playerid, false);
SetPlayerHealth(playerid, 100000);
ShowMenuForPlayer(FWeapons, playerid);
return 1;
}
return 0;
}
public OnFilterScriptExit()
{
DestroyMenu(Menu:FWeapons);
DestroyMenu(Menu:FPistols);
DestroyMenu(Menu:FMicro_SMGs);
DestroyMenu(Menu:FShotguns);
DestroyMenu(Menu:FArmour);
DestroyMenu(Menu:FSMG);
DestroyMenu(Menu:FRifles);
DestroyMenu(Menu:FAssault);
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
new Menu:Current = GetPlayerMenu(playerid);
if(Current == FWeapons) {
switch(row){
case 0:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FPistols, playerid);
}
case 1:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FMicro_SMGs, playerid);
}
case 2:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FShotguns, playerid);
}
case 3:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FArmour, playerid);
}
case 4:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FSMG, playerid);
}
case 5:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FRifles, playerid);
}
case 6:
if(IsPlayerConnected(playerid))
{
ShowMenuForPlayer(FAssault, playerid);
}
}
}
if(Current == FPistols) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 22, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
GetPlayerWeapon(playerid);
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 23, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld");
ShowMenuForPlayer(FWeapons, playerid);
}
case 2:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 24, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 3:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FMicro_SMGs) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 32, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 28, 60);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 2:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FShotguns) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 25, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 26, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 2:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FArmour) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
SetPlayerArmour(playerid, 100);
SendClientMessage(playerid,yellow,"Armour gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FSMG) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 29, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FRifles) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 33, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 34, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 2:ShowMenuForPlayer(FWeapons, playerid);
}
}
if(Current == FAssault) {
switch(row){
case 0:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 30, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 1:
if(GetPlayerMoney(playerid) >= 0)
{
GivePlayerWeapon(playerid, 31, 500);
SendClientMessage(playerid,yellow,"Waffe gekauft!");
ShowMenuForPlayer(FWeapons, playerid);
}
else
{
SendClientMessage(playerid,red,"Du hast nicht genug Geld!");
ShowMenuForPlayer(FWeapons, playerid);
}
case 2:ShowMenuForPlayer(FWeapons, playerid);
}
}
}
public OnPlayerExitedMenu(playerid)
{
TogglePlayerControllable(playerid, true);
(SetPlayerHealth(playerid, Float:health));
}