Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <DOF2>
- #include <Zcmd>
- #define FOLDER_WEAPONS "Weapons/%s.ini"
- #define SaveStats 0
- #define GetStats 1
- const DIALOG_WEAPONS = 1000;
- enum WEAPON_DATA
- {
- WEAPON_ID,
- WEAPON_AMMUNITION,
- WEAPON_NAME[40]
- };
- static const WEAPON_DATA_PLAYER[][WEAPON_DATA] =
- {
- { 24, 500, "Desert" },
- { 25, 500, "Escopeta" },
- { 29, 500, "MP - 5" },
- { 30, 1500, "AK - 47" },
- { 31, 1500, "M4" },
- { 27, 500, "SPAS - 12" },
- { 34, 500, "Snipe Rifle" },
- { 16, 3, "Granada" },
- { 9, 999, "MotoSerra" }
- };
- new bool: IsWeaponActived[MAX_PLAYERS][sizeof(WEAPON_DATA_PLAYER)], Name[MAX_PLAYERS][MAX_PLAYER_NAME];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("System Weapons Spawn");
- print("Development By: FerrariL\n");
- print("\n--------------------------------------");
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, Name[playerid], MAX_PLAYER_NAME);
- WeaponsVerify(playerid);
- WeaponsAcess(playerid, GetStats);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- WeaponsAcess(playerid, SaveStats);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerWeapon(playerid);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_WEAPONS)
- {
- if(response)
- {
- IsWeaponActived[playerid][listitem] = !IsWeaponActived[playerid][listitem];
- DialogWeapons(playerid);
- }
- return 1;
- }
- return 0;
- }
- CMD:armas(playerid)
- return DialogWeapons(playerid);
- DialogWeapons(playerid)
- {
- new Message[295];
- strcat(Message,"Arma\tStatus\n");
- for(new i = 0; i < 9; i++)
- format(Message, sizeof(Message), "%s\n %s\t%s\n", Message, WEAPON_DATA_PLAYER[i][WEAPON_NAME], IsWeaponActived[playerid][i] ? ("{3a8423}Habilitado") : ("{ba1d22}Desabilitado"));
- return ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_TABLIST_HEADERS, "Armas", Message, "Selecionar", "Sair");
- }
- SetPlayerWeapon(playerid)
- {
- for(new i = 0; i < sizeof(WEAPON_DATA_PLAYER); i++)
- {
- if(!IsWeaponActived[playerid][i])
- continue;
- GivePlayerWeapon(playerid, WEAPON_DATA_PLAYER[i][WEAPON_ID], WEAPON_DATA_PLAYER[i][WEAPON_AMMUNITION]);
- }
- }
- GetFolderPlayer(playerid)
- {
- new File[37];
- format(File, sizeof(File), FOLDER_WEAPONS, Name[playerid]);
- return File;
- }
- WeaponsVerify(playerid)
- {
- new Aux[60];
- if(!DOF2_FileExists( GetFolderPlayer(playerid) ))
- {
- DOF2_CreateFile( GetFolderPlayer(playerid) );
- for(new i = 0; i < sizeof(WEAPON_DATA_PLAYER); i++)
- {
- format(Aux, sizeof(Aux), "Status Arma %d", i);
- DOF2_SetBool(GetFolderPlayer(playerid), Aux, IsWeaponActived[playerid][i]);
- }
- }
- }
- WeaponsAcess(playerid, Acess)
- {
- new Aux[60];
- for(new i = 0; i < sizeof(WEAPON_DATA_PLAYER); i++)
- {
- format(Aux, sizeof(Aux), "Status Arma %d", i);
- if(Acess == SaveStats)
- DOF2_SetBool(GetFolderPlayer(playerid), Aux, IsWeaponActived[playerid][i]);
- else
- IsWeaponActived[playerid][i] = DOF2_GetBool(GetFolderPlayer(playerid), Aux);
- }
- DOF2_SaveFile();
- }
Advertisement
Add Comment
Please, Sign In to add comment