SA-MP Forums Archive
[FilterScript] Weapon Menu (Simple) - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Weapon Menu (Simple) (/showthread.php?tid=643401)



Weapon Menu (Simple) - DonaldDuck - 19.10.2017

/Weapons to open the menu

LSHIFT to select


Code:
/*x---------------------------------Important-------------------------------------x*/
//**INCLUDES**//
#include <a_samp>
/*x---------------------------------Defining-------------------------------------x*/
//**COLORS**//
#define GREEN 0x21DD00FF
#define RED 0xE60000FF
#define ADMIN_RED 0xFB0000FF
#define YELLOW 0xFFFF00FF
#define ORANGE 0xF97804FF
#define LIGHTRED 0xFF8080FF
#define LIGHTBLUE 0x00C2ECFF
#define PURPLE 0xB360FDFF
#define PLAYER_COLOR 0xFFFFFFFF
#define BLUE 0x1229FAFF
#define LIGHTGREEN 0x38FF06FF
#define DARKPINK 0xE100E1FF
#define DARKGREEN 0x008040FF
#define ANNOUNCEMENT 0x6AF7E1FF
#define COLOR_SYSTEM 0xEFEFF7AA
#define GRAY 0xCECECEFF
//**MISC**//
#define WEAPAMMO 500 // Weapon Ammo when the weapon is selected.
#undef KEY_LEFT
#define KEY_LEFT 65408
//**VARIABLES**//
new Weap;
new Weapons[200];
new WeaponSelecting[45][0] = {
{321},
{322},
{323},
{324},
{325},
{326},
{330},
{331},
{333},
{334},
{335},
{336},
{337},
{338},
{339},
{341},
{342},
{343},
{344},
{346},
{347},
{348},
{349},
{350},
{351},
{352},
{353},
{354},
{355},
{356},
{357},
{358},
{359},
{360},
{361},
{362},
{363},
{364},
{365},
{366},
{367},
{368},
{369},
{371},
{372}
};
new AllWeapons[45][0] = {
{10},
{11},
{12},
{13},
{14},
{15},
{0},
{1},
{2},
{3},
{4},
{5},
{6},
{7},
{8},
{9},
{16},
{17},
{18},
{22},
{23},
{24},
{25},
{26},
{27},
{28},
{29},
{0},
{30},
{31},
{33},
{34},
{35},
{36},
{37},
{38},
{39},
{40},
{41},
{42},
{43},
{44},
{45},
{46},
{32}
};
//**FORWARDS**//
forward WeaponSelection(playerid);
/*x---------------------------------CallBacks-------------------------------------x*/
public OnFilterScriptInit()
{
	print("[FS]|-----------------------------------------|[FS]");
	print("[FS]|  .:[ - Simple Weapon Menu by DonaldDuck - ]:. |[FS]");
	print("[FS]|-----------------------------------------|[FS]");
	return 1;
}

public OnFilterScriptExit()
{
	print("[FS]|---------------[UNLOADED]----------------|[FS]");
	print("[FS]|  .:[ - Simple Weapon Menu by DonaldDuck - ]:. |[FS]");
	print("[FS]|---------------[UNLOADED]----------------|[FS]");
	DestroyPickup(Weap);
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/weapons", cmdtext, true, 10) == 0)
	{
	    new string[256],weapname[50];
        SetPlayerCameraPos(playerid,2238,1090,40);
        SetPlayerCameraLookAt(playerid,2233,1090,40);
        TogglePlayerControllable(playerid,0);
        Weapons[playerid] = 1;
        Weap = CreatePickup(WeaponSelecting[0][0],23,2233,1090,40);
        GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
		GameTextForPlayer(playerid,string,3000,3);
        SetTimerEx("WeaponSelection",100,1,"i",playerid);
	    return 1;
	}
	return 0;
}

public WeaponSelection()
{
	for (new playerid=0;playerid<200;playerid++)
	{
	new keys, updown, leftright,weapname[50],string[128];
	GetPlayerKeys(playerid,keys,updown,leftright);
	switch (Weapons[playerid])
	{
		case 1:
		{
			if (leftright & 128)
			{
			    DestroyPickup(Weap);
	 	 		Weap = CreatePickup(WeaponSelecting[1][0],23,2233,1090,40);
	 	 		Weapons[playerid] = 2;
	 	 		GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(leftright & 65408)
			{
			    DestroyPickup(Weap);
			    Weap = CreatePickup(WeaponSelecting[44][0],23,2233,1090,40);
			    Weapons[playerid] = 44;
			    GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(keys & 16)
			{
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
			else if(keys & 32)
			{
			    GivePlayerWeapon(playerid,AllWeapons[Weapons[playerid]][0],WEAPAMMO);
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
		}
		case 2..43:
		{
			if (leftright & 128)
			{
			    DestroyPickup(Weap);
	 	 		Weap = CreatePickup(WeaponSelecting[Weapons[playerid]+1][0],23,2233,1090,40);
	 	 		Weapons[playerid]++;
	 	 		GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(leftright & 65408)
			{
			    DestroyPickup(Weap);
			    Weap = CreatePickup(WeaponSelecting[Weapons[playerid]-1][0],23,2233,1090,40);
			    Weapons[playerid]--;
			    GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(keys & 16)
			{
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
			else if(keys & 32)
			{
			    GivePlayerWeapon(playerid,AllWeapons[Weapons[playerid]][0],WEAPAMMO);
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
		}
		case 44:
		{
			if (leftright & 128)
			{
			    DestroyPickup(Weap);
	 	 		Weap = CreatePickup(WeaponSelecting[0][0],23,2233,1090,40);
	 	 		Weapons[playerid] = 1;
	 	 		GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(leftright & 65408)
			{
			    DestroyPickup(0);
			    Weap = CreatePickup(WeaponSelecting[43][0],23,2233,1090,40);
			    Weapons[playerid] = 43;
			    GetWeaponName(AllWeapons[Weapons[playerid]][0],weapname,50);
	 	 		format(string,128,"~n~~n~~n~~n~~n~~n~~n~~n~~g~~h~%s",weapname);
	 	 		GameTextForPlayer(playerid,string,3000,3);
			}
			else if(keys & 16)
			{
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
			else if(keys & 32)
			{
			    GivePlayerWeapon(playerid,AllWeapons[Weapons[playerid]][0],WEAPAMMO);
			    Weapons[playerid] = 0;
			    DestroyPickup(Weap);
			    SetCameraBehindPlayer(playerid);
			    TogglePlayerControllable(playerid,1);
			}
		}
	}
	}
	return 1;
}



Re: Weapon Menu (Simple) - justice96 - 19.10.2017

What is this for? you don\'t even put a description of the system. I can guess it that is for weapon drops


Re: Weapon Menu (Simple) - Zeth - 19.10.2017

I finally got, that ducks are not for scripting.


Re: Weapon Menu (Simple) - DonaldDuck - 19.10.2017

Quote:
Originally Posted by justice96
View Post
What is this for? you don\'t even put a description of the system. I can guess it that is for weapon drops
Its just a weapon menu, you can select weapon buy using /weapons and press LSHIFT to select..


Re: Weapon Menu (Simple) - Ponga - 19.10.2017

It could be useful in freeroam. thanks +rep


Re: Weapon Menu (Simple) - JustMe.77 - 19.10.2017

Trash


Re: Weapon Menu (Simple) - FreAkeD - 19.10.2017

Quote:
Originally Posted by JustMe.77
View Post
Trash
Instead of going around saying that, why don\'t you actually say what is \'trash\' about this, and how it can be improved??


OT: Good job - although many things could be improved especially the spacing of everything, it was kind of hard to read. Also the color macros, you maybe could of named them something like \'COLOR_COLORNAMEHERE\' or something.


Re: Weapon Menu (Simple) - NaS - 19.10.2017

Code:
for (new playerid=0;playerid<200;playerid++)
Use MAX_PLAYERS instead of 200. Or foreach (and create an iterator for players that are in the weapon menu).


Also the switch in the loop is totally unneccessary..


Re: Weapon Menu (Simple) - darkhunter332 - 19.10.2017

Nice work ducky, may i pet you?


Re: Weapon Menu (Simple) - KaryM4Life - 19.10.2017

Too simple :/ There are many weapon shops/Menus on this forum, Try to find something new.


Off topic:
Quote:
Originally Posted by Debjit
View Post
I finally got, that ducks are not for scripting.
Nope, Ducks are good at everything if you knew Uncle $crooge You wouldn\'t say that !


But uncle $crooge\'s nephew (Donald duck) Is not good at anything :P


Re: Weapon Menu (Simple) - Bolex_ - 19.10.2017

Original credits ?


Re: Weapon Menu (Simple) - Coraxx - 19.10.2017

Thanks.. +Rep