Need help with making a gun menu
#1

Im trying to make a gun shop menu but im not sure what to do for them to get the gun and for their money to be taken away so can some help?

This is the code i have and can u correct it please
Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
new Menu:CurrentMenu = GetPlayerMenu(playerid);
if(CurrentMenu == gunmenu)
{
  switch(row)
  {
    case 0: //M4
    {

      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought an M4");
    }
    case 1: //AK47
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a AK47");
    }
    case 2: //Sniper Rifle
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Sniper Rifle");
    }
    case 3: //Sawn-Off Shotgun
    {
			 SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Sawn-Off Shotgun");
    }
    case 4: //Combat Shotgun
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Combat Shotgun");
    }
    case 5: //Nuke <- Gives player a right or something to do a /nuke command.
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Nuke");
    }
}
	return 1;
}
Reply
#2

Hello lilswizy,

I hope this is what youґre looking for.

pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
new Menu:CurrentMenu = GetPlayerMenu(playerid);
if(CurrentMenu == gunmenu)
{
  switch(row)
  {
    case 0: //Okay, to explain you  The if(... looks if the player has enaugh money, and if not, he returns.
        // The GivePlayerWeapon gives him the weapon, then ammo
        // GivePlayerMoney makes his money 10 000$ lower
        // Then the message
    {
      if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 31, 900);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought an M4");
    }
    case 1: //AK47
    {
      if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 30, 900);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a AK47");
    }
    case 2: //Sniper Rifle
    {
      if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 34, 900);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Sniper Rifle");
    }
    case 3: //Sawn-Off Shotgun
    {
            if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 26, 900);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Sawn-Off Shotgun");
    }
    case 4: //Combat Shotgun
    {
      if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 27, 900);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Combat Shotgun");
    }
    case 5: //Nuke <- Gives player a right or something to do a /nuke command.
    {
      if(GetPlayerMoney(playerid)<10000) return SendClientMessage(playerid, 0xFF0000AA, "You donґt have enaugh money.");
            GivePlayerWeapon(playerid, 3, 1);
            GivePlayerMoney(playerid, -10000);
      SendClientMessage(playerid, 0xFFFFFFFF, "You Bought a Nuke");
    }
}

}
return 1;
}
And the command if you want so:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/guns", cmdtext, true) == 0)
    {
        ShowMenuForPlayer(gunmenu, playerid);
        return 1;
    }
    return 0;
}
Its untested, but it should work.

Do you need any other help, or have questions to this?
Just ask.


Jeffry
Reply
#3

Im really not good at scripting if u can pm me ur msn or xfire maybe u can help me?

Thanks but it didnt work:
Код:
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(47) : error 017: undefined symbol "gunmenu"
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(49) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(179) : error 021: symbol already defined: "SetPlayerPos"
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(182) : error 010: invalid function or declaration
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(196) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(199) : error 017: undefined symbol "gunmenu"
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(204) : warning 225: unreachable code
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(204) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(210) : error 017: undefined symbol "gunmenu"
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(220) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(222) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(227) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(229) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(234) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(236) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(243) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(248) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(250) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(255) : warning 217: loose indentation
C:\Documents and Settings\EMINEM\My Documents\Alex\samp03asvr_R4_win32\gamemodes\sarp.pwn(257) : warning 217: loose indentation
Reply
#4

Oje, alot of little mistakes, but not in the part I gave you. Compiled fine for me.

Well, XFire then (tomorrow).
I read your PMs.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)