Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- #include <ZCMD>
- #include <DOF2>
- #if defined FILTERSCRIPT
- #define Inventarios "Inventarios/%s.ini"
- enum pInv
- {
- iSlot[8]
- };
- new PlayerInventario[MAX_PLAYERS][pInv];
- new PlayerText:TDEditor_PTD[MAX_PLAYERS][13];
- new pName[MAX_PLAYERS][24];
- new gstring[20];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Inventario carregado com sucesso! ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_Exit();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, pName[playerid], 24);
- LoadInventario(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SaveInventario(playerid);
- return 1;
- }
- public OnPlayerClickTextDraw(playerid, Text:clickedid){
- if(clickedid == Text:INVALID_TEXT_DRAW){
- if(GetPVarInt(playerid, "Inventario")){
- InventarioHide(playerid);
- }
- }
- return 1;
- }
- CMD:test(playerid)
- {
- if(!GetPVarInt(playerid, "Inventario")){
- LoadInventario(playerid);
- Inventario(playerid);
- InventarioShow(playerid);
- }
- else{
- SaveInventario(playerid);
- InventarioHide(playerid);
- }
- return 1;
- }
- GetPlayerArquivo(playerid)
- {
- new ArquivoPlayer[ 30 ];
- format( ArquivoPlayer, sizeof( ArquivoPlayer ), Inventarios, pName[playerid]);
- return ArquivoPlayer;
- }
- SaveInventario(playerid)
- {
- for(new I; I < 8; I ++)
- {
- if(PlayerInventario[playerid][iSlot][I] == 0)
- {
- PlayerInventario[playerid][iSlot][I] = 1;
- if(!DOF2_FileExists(GetPlayerArquivo(playerid)))
- DOF2_CreateFile(GetPlayerArquivo(playerid));
- format(gstring, sizeof(gstring), "iSlot%d", I);
- DOF2_SetInt(GetPlayerArquivo(playerid), gstring, PlayerInventario[playerid][iSlot][I]);
- DOF2_SaveFile();
- }
- }
- return 1;
- }
- LoadInventario(playerid)
- {
- if( DOF2_FileExists( GetPlayerArquivo(playerid) ) )
- {
- for(new I; I < 8; I ++) {
- format(gstring, sizeof(gstring), "iSlot%d", I);
- PlayerInventario[playerid][iSlot][I] = DOF2_GetInt(GetPlayerArquivo(playerid), gstring);
- }
- }
- return 1;
- }
- InventarioHide(playerid)
- {
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][0]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][1]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][2]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][3]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][4]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][5]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][6]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][7]);
- PlayerTextDrawHide(playerid, TDEditor_PTD[playerid][8]);
- CancelSelectTextDraw(playerid);
- SetPVarInt(playerid, "Inventario", 0);
- return 1;
- }
- InventarioShow(playerid)
- {
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][0]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][1]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][2]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][3]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][4]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][5]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][6]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][7]);
- PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][8]);
- return 1;
- }
- Inventario(playerid)
- {
- TDEditor_PTD[playerid][0] = CreatePlayerTextDraw(playerid, 188.125000, 148.583358, "Inventario");
- TDEditor_PTD[playerid][1] = CreatePlayerTextDraw(playerid, 181.875000, 148.000045, "box");
- TDEditor_PTD[playerid][2] = CreatePlayerTextDraw(playerid, 204.375000, 168.416595, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][2], PlayerInventario[playerid][iSlot][0]);
- TDEditor_PTD[playerid][3] = CreatePlayerTextDraw(playerid, 323.125000, 168.416595, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][3], PlayerInventario[playerid][iSlot][1]);
- TDEditor_PTD[playerid][4] = CreatePlayerTextDraw(playerid, 429.375000, 167.249938, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][4], PlayerInventario[playerid][iSlot][2]);
- TDEditor_PTD[playerid][5] = CreatePlayerTextDraw(playerid, 203.125000, 247.749954, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][5], PlayerInventario[playerid][iSlot][3]);
- TDEditor_PTD[playerid][6] = CreatePlayerTextDraw(playerid, 321.875000, 248.916656, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][6], PlayerInventario[playerid][iSlot][4]);
- TDEditor_PTD[playerid][7] = CreatePlayerTextDraw(playerid, 433.125000, 247.750045, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][7], PlayerInventario[playerid][iSlot][5]);
- TDEditor_PTD[playerid][8] = CreatePlayerTextDraw(playerid, 431.250000, 247.750045, "");
- PlayerTextDrawSetPreviewModel(playerid, TDEditor_PTD[playerid][8], PlayerInventario[playerid][iSlot][6]);
- SetPVarInt(playerid, "Inventario", 1);
- return 1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement