SA-MP Forums Archive
How to add GivePlayerWeapon to menus - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to add GivePlayerWeapon to menus (/showthread.php?tid=85518)



How to add GivePlayerWeapon to menus - killdahobo99 - 08.07.2009

This is my Menu Script

http://pastebin.com/m424b0cc2

How do i add GivePlayerWeapon if they teleport to a certain location? like say they teleport to Mount Chilliad (its located in my Menu script) I want to give them a certain weapon and ResetPlayerWeapon so if they have one, it resets it.


I want different weapons for each place, but i'm not sure how to do it...Can someone help me.


Re: How to add GivePlayerWeapon to menus - troy52192 - 08.07.2009

Код:
new Menu:XWeapons, Menu:XWeaponsBig, Menu:XWeaponsSmall, Menu:XWeaponsMore;

 	XWeapons = CreateMenu("~b~Weapons ~g~Main Menu",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeapons, 0, "Choose a weapon");
	AddMenuItem(XWeapons,0,"Desert Eagle");//0
	AddMenuItem(XWeapons,0,"M4");
	AddMenuItem(XWeapons,0,"Sawnoff Shotgun");
	AddMenuItem(XWeapons,0,"Combat Shotgun");
	AddMenuItem(XWeapons,0,"UZI");
	AddMenuItem(XWeapons,0,"Rocket Launcher");
	AddMenuItem(XWeapons,0,"Minigun");//6
	AddMenuItem(XWeapons,0,"Sniper Rifle");
	AddMenuItem(XWeapons,0,"Big Weapons");
	AddMenuItem(XWeapons,0,"Small Weapons");//9
	AddMenuItem(XWeapons,0,"More");
	AddMenuItem(XWeapons,0,"Return");//11

 	XWeaponsBig = CreateMenu("~b~Weapons ~g~Big Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsBig,0,"Shotgun");
	AddMenuItem(XWeaponsBig,0,"AK-47");
	AddMenuItem(XWeaponsBig,0,"Country Rifle");
	AddMenuItem(XWeaponsBig,0,"HS Rocket Launcher");
	AddMenuItem(XWeaponsBig,0,"Flamethrower");
	AddMenuItem(XWeaponsBig,0,"SMG");
	AddMenuItem(XWeaponsBig,0,"TEC9");
	AddMenuItem(XWeaponsBig,0,"Return");

 	XWeaponsSmall = CreateMenu("~b~Weapons ~g~Small Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsSmall,0,"9mm");
	AddMenuItem(XWeaponsSmall,0,"Silenced 9mm");
	AddMenuItem(XWeaponsSmall,0,"Molotov Cocktail");
	AddMenuItem(XWeaponsSmall,0,"Fire Extinguisher");
	AddMenuItem(XWeaponsSmall,0,"Spraycan");
	AddMenuItem(XWeaponsSmall,0,"Frag Grenades");
	AddMenuItem(XWeaponsSmall,0,"Katana");
	AddMenuItem(XWeaponsSmall,0,"Chainsaw");
	AddMenuItem(XWeaponsSmall,0,"Return");

 	XWeaponsMore = CreateMenu("~b~Weapons ~g~More Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsMore,0,"Jetpack");
	AddMenuItem(XWeaponsMore,0,"Knife");
	AddMenuItem(XWeaponsMore,0,"Flowers");
	AddMenuItem(XWeaponsMore,0,"Camera");
	AddMenuItem(XWeaponsMore,0,"Pool Cue");
	AddMenuItem(XWeaponsMore,0,"Baseball Bat");
	AddMenuItem(XWeaponsMore,0,"Golf Club");
	AddMenuItem(XWeaponsMore,0,"MAX AMMO");
	AddMenuItem(XWeaponsMore,0,"Return");

public OnPlayerSelectedMenuRow(playerid, row){
	new Menu:Current = GetPlayerMenu(playerid);
	if(Current==XWeapons){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,24,500); }
			case 1: { GivePlayerWeapon(playerid,31,500); }
			case 2: { GivePlayerWeapon(playerid,26,500); }
			case 3: { GivePlayerWeapon(playerid,27,500); }
			case 4: { GivePlayerWeapon(playerid,28,500); }
			case 5: { GivePlayerWeapon(playerid,35,500); }
			case 6: { GivePlayerWeapon(playerid,38,1000); }
			case 7: { GivePlayerWeapon(playerid,34,500); }
			case 8: return ChangeMenu(playerid,Current,XWeaponsBig);
    	case 9: return ChangeMenu(playerid,Current,XWeaponsSmall);
    	case 10: return ChangeMenu(playerid,Current,XWeaponsMore);
    	case 11: return ChangeMenu(playerid,Current,LMainMenu);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsBig){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,25,500); }
			case 1: { GivePlayerWeapon(playerid,30,500); }
			case 2: { GivePlayerWeapon(playerid,33,500); }
			case 3: { GivePlayerWeapon(playerid,36,500); }
			case 4: { GivePlayerWeapon(playerid,37,500); }
			case 5: { GivePlayerWeapon(playerid,29,500); }
			case 6: { GivePlayerWeapon(playerid,32,1000); }
			case 7: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsSmall){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,22,500); }//9mm
			case 1: { GivePlayerWeapon(playerid,23,500); }//s9
			case 2: { GivePlayerWeapon(playerid,18,500); }// MC
			case 3: { GivePlayerWeapon(playerid,42,500); }//FE
			case 4: { GivePlayerWeapon(playerid,41,500); }//spraycan
			case 5: { GivePlayerWeapon(playerid,16,500); }//grenade
			case 6: { GivePlayerWeapon(playerid,8,500); }//Katana
			case 7: { GivePlayerWeapon(playerid,9,1000); }//chainsaw
			case 8: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsMore){
		switch(row){
			case 0: SetPlayerSpecialAction(playerid, 2);
			case 1: GivePlayerWeapon(playerid,4,500);
			case 2: GivePlayerWeapon(playerid,14,500);
			case 3: GivePlayerWeapon(playerid,43,500);
			case 4: GivePlayerWeapon(playerid,7,500);
			case 5: GivePlayerWeapon(playerid,5,500);
			case 6: GivePlayerWeapon(playerid,2,1000);
			case 7: MaxAmmo(playerid);
			case 8: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

 //command
	if (strcmp(cmdtext, "/weapons", true) == 0){
	ShowMenuForPlayer(XWeapons,playerid);
	return 1;}



Re: How to add GivePlayerWeapon to menus - killdahobo99 - 08.07.2009

Quote:
Originally Posted by troy52192
Код:
new Menu:XWeapons, Menu:XWeaponsBig, Menu:XWeaponsSmall, Menu:XWeaponsMore;

 	XWeapons = CreateMenu("~b~Weapons ~g~Main Menu",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeapons, 0, "Choose a weapon");
	AddMenuItem(XWeapons,0,"Desert Eagle");//0
	AddMenuItem(XWeapons,0,"M4");
	AddMenuItem(XWeapons,0,"Sawnoff Shotgun");
	AddMenuItem(XWeapons,0,"Combat Shotgun");
	AddMenuItem(XWeapons,0,"UZI");
	AddMenuItem(XWeapons,0,"Rocket Launcher");
	AddMenuItem(XWeapons,0,"Minigun");//6
	AddMenuItem(XWeapons,0,"Sniper Rifle");
	AddMenuItem(XWeapons,0,"Big Weapons");
	AddMenuItem(XWeapons,0,"Small Weapons");//9
	AddMenuItem(XWeapons,0,"More");
	AddMenuItem(XWeapons,0,"Return");//11

 	XWeaponsBig = CreateMenu("~b~Weapons ~g~Big Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsBig,0,"Shotgun");
	AddMenuItem(XWeaponsBig,0,"AK-47");
	AddMenuItem(XWeaponsBig,0,"Country Rifle");
	AddMenuItem(XWeaponsBig,0,"HS Rocket Launcher");
	AddMenuItem(XWeaponsBig,0,"Flamethrower");
	AddMenuItem(XWeaponsBig,0,"SMG");
	AddMenuItem(XWeaponsBig,0,"TEC9");
	AddMenuItem(XWeaponsBig,0,"Return");

 	XWeaponsSmall = CreateMenu("~b~Weapons ~g~Small Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsSmall,0,"9mm");
	AddMenuItem(XWeaponsSmall,0,"Silenced 9mm");
	AddMenuItem(XWeaponsSmall,0,"Molotov Cocktail");
	AddMenuItem(XWeaponsSmall,0,"Fire Extinguisher");
	AddMenuItem(XWeaponsSmall,0,"Spraycan");
	AddMenuItem(XWeaponsSmall,0,"Frag Grenades");
	AddMenuItem(XWeaponsSmall,0,"Katana");
	AddMenuItem(XWeaponsSmall,0,"Chainsaw");
	AddMenuItem(XWeaponsSmall,0,"Return");

 	XWeaponsMore = CreateMenu("~b~Weapons ~g~More Weapons",2, 55.0, 200.0, 100.0, 80.0);
	SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
	AddMenuItem(XWeaponsMore,0,"Jetpack");
	AddMenuItem(XWeaponsMore,0,"Knife");
	AddMenuItem(XWeaponsMore,0,"Flowers");
	AddMenuItem(XWeaponsMore,0,"Camera");
	AddMenuItem(XWeaponsMore,0,"Pool Cue");
	AddMenuItem(XWeaponsMore,0,"Baseball Bat");
	AddMenuItem(XWeaponsMore,0,"Golf Club");
	AddMenuItem(XWeaponsMore,0,"MAX AMMO");
	AddMenuItem(XWeaponsMore,0,"Return");

public OnPlayerSelectedMenuRow(playerid, row){
	new Menu:Current = GetPlayerMenu(playerid);
	if(Current==XWeapons){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,24,500); }
			case 1: { GivePlayerWeapon(playerid,31,500); }
			case 2: { GivePlayerWeapon(playerid,26,500); }
			case 3: { GivePlayerWeapon(playerid,27,500); }
			case 4: { GivePlayerWeapon(playerid,28,500); }
			case 5: { GivePlayerWeapon(playerid,35,500); }
			case 6: { GivePlayerWeapon(playerid,38,1000); }
			case 7: { GivePlayerWeapon(playerid,34,500); }
			case 8: return ChangeMenu(playerid,Current,XWeaponsBig);
    	case 9: return ChangeMenu(playerid,Current,XWeaponsSmall);
    	case 10: return ChangeMenu(playerid,Current,XWeaponsMore);
    	case 11: return ChangeMenu(playerid,Current,LMainMenu);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsBig){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,25,500); }
			case 1: { GivePlayerWeapon(playerid,30,500); }
			case 2: { GivePlayerWeapon(playerid,33,500); }
			case 3: { GivePlayerWeapon(playerid,36,500); }
			case 4: { GivePlayerWeapon(playerid,37,500); }
			case 5: { GivePlayerWeapon(playerid,29,500); }
			case 6: { GivePlayerWeapon(playerid,32,1000); }
			case 7: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsSmall){
		switch(row){
			case 0: { GivePlayerWeapon(playerid,22,500); }//9mm
			case 1: { GivePlayerWeapon(playerid,23,500); }//s9
			case 2: { GivePlayerWeapon(playerid,18,500); }// MC
			case 3: { GivePlayerWeapon(playerid,42,500); }//FE
			case 4: { GivePlayerWeapon(playerid,41,500); }//spraycan
			case 5: { GivePlayerWeapon(playerid,16,500); }//grenade
			case 6: { GivePlayerWeapon(playerid,8,500); }//Katana
			case 7: { GivePlayerWeapon(playerid,9,1000); }//chainsaw
			case 8: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

	if(Current==XWeaponsMore){
		switch(row){
			case 0: SetPlayerSpecialAction(playerid, 2);
			case 1: GivePlayerWeapon(playerid,4,500);
			case 2: GivePlayerWeapon(playerid,14,500);
			case 3: GivePlayerWeapon(playerid,43,500);
			case 4: GivePlayerWeapon(playerid,7,500);
			case 5: GivePlayerWeapon(playerid,5,500);
			case 6: GivePlayerWeapon(playerid,2,1000);
			case 7: MaxAmmo(playerid);
			case 8: return ChangeMenu(playerid,Current,XWeapons);
		}
		return TogglePlayerControllable(playerid,true);
	}

 //command
	if (strcmp(cmdtext, "/weapons", true) == 0){
	ShowMenuForPlayer(XWeapons,playerid);
	return 1;}
Can you explain this? what is it suppose to do? Like say i teleport to a certain location, will it give the person a certain weapon? please explain this a little bit...or if anyone has another idea, just let me know


Re: How to add GivePlayerWeapon to menus - killdahobo99 - 08.07.2009

No one knows how to do this? Comon guys, i know one of you mihgt


Re: How to add GivePlayerWeapon to menus - Marcel - 08.07.2009

Quote:
Originally Posted by troy52192
This goes at the top:
pawn Код:
new Menu:XWeapons, Menu:XWeaponsBig, Menu:XWeaponsSmall, Menu:XWeaponsMore;
This goes in OnFilterScriptInit or OnGameModeInit:
pawn Код:
XWeapons = CreateMenu("~b~Weapons ~g~Main Menu",2, 55.0, 200.0, 100.0, 80.0);
    SetMenuColumnHeader(XWeapons, 0, "Choose a weapon");
    AddMenuItem(XWeapons,0,"Desert Eagle");//0
    AddMenuItem(XWeapons,0,"M4");
    AddMenuItem(XWeapons,0,"Sawnoff Shotgun");
    AddMenuItem(XWeapons,0,"Combat Shotgun");
    AddMenuItem(XWeapons,0,"UZI");
    AddMenuItem(XWeapons,0,"Rocket Launcher");
    AddMenuItem(XWeapons,0,"Minigun");//6
    AddMenuItem(XWeapons,0,"Sniper Rifle");
    AddMenuItem(XWeapons,0,"Big Weapons");
    AddMenuItem(XWeapons,0,"Small Weapons");//9
    AddMenuItem(XWeapons,0,"More");
    AddMenuItem(XWeapons,0,"Return");//11

    XWeaponsBig = CreateMenu("~b~Weapons ~g~Big Weapons",2, 55.0, 200.0, 100.0, 80.0);
    SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
    AddMenuItem(XWeaponsBig,0,"Shotgun");
    AddMenuItem(XWeaponsBig,0,"AK-47");
    AddMenuItem(XWeaponsBig,0,"Country Rifle");
    AddMenuItem(XWeaponsBig,0,"HS Rocket Launcher");
    AddMenuItem(XWeaponsBig,0,"Flamethrower");
    AddMenuItem(XWeaponsBig,0,"SMG");
    AddMenuItem(XWeaponsBig,0,"TEC9");
    AddMenuItem(XWeaponsBig,0,"Return");

    XWeaponsSmall = CreateMenu("~b~Weapons ~g~Small Weapons",2, 55.0, 200.0, 100.0, 80.0);
    SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
    AddMenuItem(XWeaponsSmall,0,"9mm");
    AddMenuItem(XWeaponsSmall,0,"Silenced 9mm");
    AddMenuItem(XWeaponsSmall,0,"Molotov Cocktail");
    AddMenuItem(XWeaponsSmall,0,"Fire Extinguisher");
    AddMenuItem(XWeaponsSmall,0,"Spraycan");
    AddMenuItem(XWeaponsSmall,0,"Frag Grenades");
    AddMenuItem(XWeaponsSmall,0,"Katana");
    AddMenuItem(XWeaponsSmall,0,"Chainsaw");
    AddMenuItem(XWeaponsSmall,0,"Return");

    XWeaponsMore = CreateMenu("~b~Weapons ~g~More Weapons",2, 55.0, 200.0, 100.0, 80.0);
    SetMenuColumnHeader(XWeaponsBig, 0, "Choose a weapon");
    AddMenuItem(XWeaponsMore,0,"Jetpack");
    AddMenuItem(XWeaponsMore,0,"Knife");
    AddMenuItem(XWeaponsMore,0,"Flowers");
    AddMenuItem(XWeaponsMore,0,"Camera");
    AddMenuItem(XWeaponsMore,0,"Pool Cue");
    AddMenuItem(XWeaponsMore,0,"Baseball Bat");
    AddMenuItem(XWeaponsMore,0,"Golf Club");
    AddMenuItem(XWeaponsMore,0,"MAX AMMO");
    AddMenuItem(XWeaponsMore,0,"Return");
This goes in OnPlayerSelectedMenuRow:
pawn Код:
new Menu:Current = GetPlayerMenu(playerid);
    if(Current==XWeapons)
    {
        switch(row)
        {
            case 0: { GivePlayerWeapon(playerid,24,500); }
            case 1: { GivePlayerWeapon(playerid,31,500); }
            case 2: { GivePlayerWeapon(playerid,26,500); }
            case 3: { GivePlayerWeapon(playerid,27,500); }
            case 4: { GivePlayerWeapon(playerid,28,500); }
            case 5: { GivePlayerWeapon(playerid,35,500); }
            case 6: { GivePlayerWeapon(playerid,38,1000); }
            case 7: { GivePlayerWeapon(playerid,34,500); }
            case 8: return ChangeMenu(playerid,Current,XWeaponsBig);
            case 9: return ChangeMenu(playerid,Current,XWeaponsSmall);
            case 10: return ChangeMenu(playerid,Current,XWeaponsMore);
            case 11: return ChangeMenu(playerid,Current,LMainMenu);
        }
        return TogglePlayerControllable(playerid,true);
    }

    if(Current==XWeaponsBig)
    {
        switch(row)
        {
            case 0: { GivePlayerWeapon(playerid,25,500); }
            case 1: { GivePlayerWeapon(playerid,30,500); }
            case 2: { GivePlayerWeapon(playerid,33,500); }
            case 3: { GivePlayerWeapon(playerid,36,500); }
            case 4: { GivePlayerWeapon(playerid,37,500); }
            case 5: { GivePlayerWeapon(playerid,29,500); }
            case 6: { GivePlayerWeapon(playerid,32,1000); }
            case 7: return ChangeMenu(playerid,Current,XWeapons);
        }
        return TogglePlayerControllable(playerid,true);
    }

    if(Current==XWeaponsSmall)
    {
        switch(row)
        {
            case 0: { GivePlayerWeapon(playerid,22,500); }//9mm
            case 1: { GivePlayerWeapon(playerid,23,500); }//s9
            case 2: { GivePlayerWeapon(playerid,18,500); }// MC
            case 3: { GivePlayerWeapon(playerid,42,500); }//FE
            case 4: { GivePlayerWeapon(playerid,41,500); }//spraycan
            case 5: { GivePlayerWeapon(playerid,16,500); }//grenade
            case 6: { GivePlayerWeapon(playerid,8,500); }//Katana
            case 7: { GivePlayerWeapon(playerid,9,1000); }//chainsaw
            case 8: return ChangeMenu(playerid,Current,XWeapons);
        }
        return TogglePlayerControllable(playerid,true);
    }

    if(Current==XWeaponsMore)
    {
        switch(row)
        {
            case 0: SetPlayerSpecialAction(playerid, 2);
            case 1: GivePlayerWeapon(playerid,4,500);
            case 2: GivePlayerWeapon(playerid,14,500);
            case 3: GivePlayerWeapon(playerid,43,500);
            case 4: GivePlayerWeapon(playerid,7,500);
            case 5: GivePlayerWeapon(playerid,5,500);
            case 6: GivePlayerWeapon(playerid,2,1000);
            case 7: MaxAmmo(playerid);
            case 8: return ChangeMenu(playerid,Current,XWeapons);
        }
        return TogglePlayerControllable(playerid,true);
    }
This goes in OnPlayerCommandText:
pawn Код:
if (strcmp(cmdtext, "/weapons", true) == 0)
    {
        ShowMenuForPlayer(XWeapons,playerid);
        return 1;
    }