SA-MP Forums Archive
help me plz fast - 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)
+--- Thread: help me plz fast (/showthread.php?tid=313981)



help me plz fast - mineralo - 28.01.2012

hi, I made bug system and with cmds for use items from bug and I made cmds use for use item from bug it's doesn't saying you don't have anything in this slot but in really I have
pawn Код:
#define BAGCOUNT 5
#define MAX_ITEMS 13
#define EMPTY_BAGSPACE 0
new Bags[MAX_PLAYERS][BAGCOUNT];
new ItemNames[MAX_ITEMS][32] ={
{" "},
{"Check +20"},
{"Medikit"},
{"Bronze Medal"},
{"Silver Medal"},
{"Gold Medal"},
{"Diamond"},
{"Secret Document Part 1"},
{"Secret Document Part 2"},
{"Secret Document Part 3"},
{"Secret Document Part 4"},
{"Secret Document (complete)"},
{"S.W.A.T.'s Signature"}
};
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/use", cmd, true)) if(Logged[playerid] == 1)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "( ! ) /use <id slot>");
    new id = strlen(tmp);
    if(Bags[playerid][id] == 1)
    {
    if(ShitInfo[playerid][pBank] == 0) return scm(playerid,c_r,"( ! ) You are not in bank for use Check !");
    scm(playerid,COLOR_GREEN,"( ! ) You used Check +20 !");
    GivePlayerECash(playerid, 20);
    scm(playerid,COLOR_YELLOW,"( ! ) +20 ECash");
    Bags[playerid][id] = 0;
    SaveBag(playerid);
    }
    else if(Bags[playerid][id] == 2)
    {
    new Float:health;
    GetPlayerHealth(playerid,health);
    SetPlayerHealth(playerid,health+20);
    scm(playerid,COLOR_GREEN,"( ! ) You used medikit !");
    Bags[playerid][id] = 0;
    SaveBag(playerid);
    }
    else if(Bags[playerid][id] == 0)
    {
    scm(playerid,c_r,"( ! ) You don't have anything in this slot");
    }
    else
    {
    scm(playerid,c_r,"( ! ) You can't use this item !");
    }
    return 1;
    }
return 0;
}
stock LoadBag(playerid)
{
    new filename[256];
    format(filename, sizeof(filename), "Bags/%s.ini", Player(playerid));
    if (fexist(filename))
    {
        new File: BagFile;
        BagFile = fopen(filename, io_read);

        if(BagFile)
        {
            new key[256];
            new Data[256];
            while(fread(BagFile, Data, sizeof(Data)))
            {
                key = ini_GetKey(Data);
                if(strcmp(key, "slot:1", true)==0)
                {
                    Bags[playerid][0]=strval(ini_GetValue(Data));
                }
                if(strcmp(key, "slot:2", true)==0)
                {
                    Bags[playerid][1]=strval(ini_GetValue(Data));
                }
                if(strcmp(key, "slot:3", true)==0)
                {
                    Bags[playerid][2]=strval(ini_GetValue(Data));
                }
                if(strcmp(key, "slot:4", true)==0)
                {
                    Bags[playerid][3]=strval(ini_GetValue(Data));
                }
                if(strcmp(key, "slot:5", true)==0)
                {
                    Bags[playerid][4]=strval(ini_GetValue(Data));
                }
            }
        }
        fclose(BagFile);
    }
    return 1;
}
stock SaveBag(playerid)
{
    if(!dini_Exists(i_path(playerid))) dini_Create(i_path(playerid));
    new bagdinikey[256], bagitemline[256];
    for(new i = 0; i < BAGCOUNT; i++)
    {
        format(bagdinikey, 256, "slot:%d", i+1);
        format(bagitemline, 256, "%d", Bags[playerid][i]);
        dini_Set(i_path(playerid), bagdinikey, bagitemline);
    }
    return 1;
}
stock GetItemInSlot(playerid,slot)
{
    return Bags[playerid][slot];
}
stock Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}
stock i_path(playerid)
{
   new a[256];
   format(a, sizeof(a), "Bags/%s.ini",Player(playerid));
   return a;
}
help me plzz


Re: help me plz fast - mineralo - 28.01.2012

help plzzzzzzz, I don't know how to fix it