What's Wrong with this Menu?
#1

Okay I am creating a menu for weapons, and I am using the tutorial on SAMP Wiki, it all makes sense, but it doesn't compile.

Here is my OnGameModeInIt()
pawn Код:
public OnGameModeInit()
{
    SetGameModeText("Test gamemode");
    //----Player Class Selection
    AddPlayerClass(23,2038.5416,1342.3601,10.6719,270.0824,0,0,0,0,0,0);
    AddPlayerClass(46,1831.0970,-1682.6102,13.5469,88.3051,0,0,0,0,0,0);
    AddPlayerClass(45,1481.3297,-1748.6530,15.4453,359.7071,0,0,0,0,0,0);
    AddPlayerClass(83,723.3815,-1494.9203,1.9343,359.2792,0,0,0,0,0,0);
    AddPlayerClass(92,1126.6831,-1425.8101,15.7969,357.7497,0,0,0,0,0,0);
    //---------------------------[SERVER VEHICLES]------------------------------
    AddStaticVehicle(502,1478.9257,-1737.8595,13.2929,270.0982,0,0);
    //Weapons Menu
    Weaponsmenu = CreateMenu("Weaponsmenu", 1, 200.0, 100.0, 150.0, 150.0);
    AddMenuItem(Weaponsmenu, 0, "Sawnoff");
    AddMenuItem(Weaponsmenu, 0, "Sniper");
    AddMenuItem(Weaponsmenu, 0, "Deagle");
    AddMenuItem(Weaponsmenu, 0, "M4");
    AddMenuItem(Weaponsmenu, 0, "Tec-9");
    AddMenuItem(Weaponsmenu, 0, "MP5");
    return 1;
}
I have these near the top of my script
pawn Код:
new Menu:Weaponsmenu;
new Menu:CurrentMenu = GetPlayerMenu(playerid);
Here is my "if" things, I don't know where to place this in the script
pawn Код:
if (CurrentMenu == Weaponsmenu)
{
    switch(row)
    {
        case 0: //Sawnoff
        {
            GivePlayerWeapon(playerid, 26, 500);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given a Sawnoff");
        }
        case 1: //Sniper
        {
            GivePlayerWeapon(playerid, 34, 50);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given a Sniper");
        }
        case 2: //Deagle
        {
            GivePlayerWeapon(playerid, 24, 250);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given a Deagle");
        }
        case 3: //M4
        {
            GivePlayerWeapon(playerid, 31, 300);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given an M4");
        }
        case 4: //Tec-9
        {
            GivePlayerWeapon(playerid, 32, 500);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given a Tec-9");
        }
        case 5: //MP5
        {
            GivePlayerWeapon(playerid, 29, 350);
            SendClientMessage(playerid, 0xFFFFFFFF, "You have been given an MP5");
        }
    }
}
Finally here is the command to bring the menu on the screen
pawn Код:
if (strcmp("/weapons", cmdtext, true, 8))
    {
        ShowMenuForPlayer(weaponsmenu,playerid);
        return 1;
    }
Thanks for reading, I hope you can help me
Reply
#2

I got the menu to work, but now when I do /weapons it gives me armor, and when I do /armor it brings up the weapons menu.

Here is my OnPlayerCommandText

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/weapons", cmdtext, true, 8))
    {
        ShowMenuForPlayer(Weaponsmenu, playerid);
        return 1;
    }

    if (strcmp("/armor", cmdtext, true, 6))
{
    SetPlayerArmour(playerid, 100.0);
    SendClientMessage(playerid, 0xFFFFFF, "You now have 100 armor.");
    return 1;
}
    return 0;
}
Reply
#3

Dont start scripting in strcmp if you are newbie since the system is slow and sucks use zcmd instead better and alot more easy to understand
Reply
#4

lol, that looks correct to me... I dont see why they would get switched...
Reply
#5

Hmm okay, I will try with ZCMD: but I actually like strcmp better
Reply
#6

if you need help with zcmd you can ask me not sure if i can fix it but got some knowledge
Reply
#7

Trust me and Pk93, ZCMD = BEST... Dcmd is fast and reliable, but i don't like it... Strcmp, isn't even meant to be used for making commands, strcmp is made for comparing strings, (string-compare)
Reply
#8

Hmm is there a place I can go to for tutorials with Zcmd?
Reply
#9

I converted my weapons command to Zcmd (I think)

Please tell me if I have any errors in this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    command(weapons,playerid,params[]);
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Weapons", "Deagle\nAK-47", "Purchase", "Cancel");
    return 1;
}
    return 0;
}
My dialog works fine with strcmp :P
Reply
#10

Quote:
Originally Posted by Zach7
Посмотреть сообщение
I converted my weapons command to Zcmd (I think)

Please tell me if I have any errors in this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    command(weapons,playerid,params[]);
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Weapons", "Deagle\nAK-47", "Purchase", "Cancel");
    return 1;
}
    return 0;
}
My dialog works fine with strcmp :P
You make commands with ZCMD as you're making a stock function.
https://sampforum.blast.hk/showthread.php?tid=91354
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)