[Ajuda]Algo errado
#1

tem algo errado?
pawn Код:
public areaagencia()
{
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i)) {
if(IsPlayerInArea(i, 1208,455, -1855,563, 1307,329, -1729,235)){
SaveWeapons(i);
ResetPlayerWeapons(i);
}else{
LoadWeapons(i);
}
}
return 1;
}
Reply
#2

Sim .


Arrumei e identei pra vocк, leia os comentбrios :


pawn Код:
public areaagencia()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInArea(i, 1208,455, -1855,563, 1307,329, -1729,235))
        {
            SaveWeapons(i);
            ResetPlayerWeapons(i);
        }//Faltou essa chave aqui.
        else //Esse else estava mal colocado.
        {
            LoadWeapons(i);
        }
    }
    return 1;
}


Espero ter ajudado .
Reply
#3

vlw
Reply
#4

pawn Код:
public areaagencia()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInArea(i, 1208,455, -1855,563, 1307,329, -1729,235))
            {
                SaveWeapons(i);
                ResetPlayerWeapons(i);
            }
            else
            {
                LoadWeapons(i);
            }
        }
     }
     return 1;
}
Tente identar seu cуdigo para obter melhores resultados!
Reply
#5

quando entra na area ele desarma... mas quando ele sai ele n carrega elas novamente

alguem sabe oq pode ser?
Reply
#6

Poste a callback/stock SaveWeapons e LoadWeapons.
Reply
#7

Posta LoadWeapons e SaveWeapons.

O erro deve tб em uma delas
Reply
#8

pawn Код:
stock LoadWeapons(playerid)
{
    new File:arquivo, tmp[256], fname[30], pname[30], arma[13], municao[13];
    arquivo = fopen(WEAPON_FILE, io_read);
    GetPlayerName(playerid, pname, sizeof pname);
    while(fread(arquivo, tmp, sizeof tmp, false))
    {
        new off[256], index;
        off = strtok(tmp, index);
        strmid(fname, off, 0, strlen(off));
        if(strcmp(pname, fname, false) != 0)continue;
        for(new a; a < 12; a++)arma[a] = strval(strtok(tmp, index));
        for(new m; m < 12; m++)municao[m] = strval(strtok(tmp, index));
        for(new i; i < 12; i++)
        {
            if(arma[i] > 0 && arma[i] < 47 && municao[i] > 0)GivePlayerWeapon(playerid, arma[i], municao[i]);
        }
    }
    fclose(arquivo);
    return 1;
}

stock SaveWeapons(playerid)
{
    new File:arquivo, File:ftmp, tmp[256], fname[30], pname[30], arma[13], municao[13];
    arquivo = fopen(WEAPON_FILE, io_readwrite);
    ftmp = fopen(WEAPON_FILE#.tmp, io_write);
    GetPlayerName(playerid, pname, sizeof pname);
    while(fread(arquivo, tmp, sizeof tmp, false))
    {
        new off[256], index;
        off = strtok(tmp, index);
        strmid(fname, off, 0, strlen(off));
        if(!strcmp(pname, fname, false))continue;
        format(tmp, sizeof tmp, "%s", tmp);
        fwrite(ftmp, tmp);
    }
    fclose(arquivo);
    fclose(ftmp);
    fremove(WEAPON_FILE);
    arquivo = fopen(WEAPON_FILE, io_write);
    ftmp = fopen(WEAPON_FILE#.tmp, io_read);
    while(fread(ftmp, tmp))
    {
        format(tmp, sizeof tmp, "%s", tmp);
        fwrite(arquivo, tmp);
    }
    fclose(ftmp);
    fremove(WEAPON_FILE#.tmp);
    for(new i; i < 12; i++)GetPlayerWeaponData(playerid, i+1, arma[i+1], municao[i+1]);
    format(tmp, sizeof tmp, "%s ", pname);
    for(new a; a < 24; a++)
    {
        new s[10];
        if(a < 12)
        {
            format(s, sizeof s, "%d ", arma[a]);
            strcat(tmp, s);
        } else {
            format(s, sizeof s, "%d ", municao[a-12]);
            strcat(tmp, s);
        }
    }
    strcat(tmp, "\r\n");
    fwrite(arquivo, tmp);
    fclose(arquivo);
    return 1;
}
Reply
#9

ngm? ele ainda nao carrega os weapons ao sair da area D:
Reply
#10

pawn Код:
stock SaveWeapons(playerid)
{
    new pharrel[128], string_[29], weapon, ammo;
    for(new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid, i, weapon, ammo);
        format(string_, 5,"%d%d",weapon,ammo);
        strcat(pharrel, string_);
    }
    GetPlayerName(playerid, string_, 24);
    format(string_, 29, "%s.ini", string_);
    new File:arquivo = fopen(string_, io_read);
    fwrite(arquivo, pharrel);
    fclose(arquivo);
    return 1;
}

stock LoadWeapons(playerid)
{
    new string_[29], pharrel[128], weapon[13], ammo[13];
    format(string_, 29, "%s.ini", string_);
    new File:arquivo = fopen(string_, io_read);
    fread(arquivo, pharrel, 128);
    fclose(arquivo);
    fremove(arquivo);
    unformat(pharrel, "dddddddddddddddddddddddd",
    weapon[0],ammo[0],weapon[1],ammo[1],weapon[2],ammo[2],weapon[3],ammo[3],weapon[4],ammo[4],weapon[5],ammo[5],weapon[6],
    ammo[6],weapon[7],ammo[7],weapon[8],ammo[8],weapon[9],ammo[9],weapon[10],ammo[10],weapon[11],ammo[11],weapon[12],ammo[12]);
    for(new i=0; i<13; i++)
    {
        if(ammo[i] > 0);
            GivePlayerWeapon(playerid, weapon[i], ammo[i]);
    }
    return 1;
}
Refiz o codigo pra vc pq seu codigo tava muito blйch...

vc vai precisar do plugin sscanf2

Se vc quiser salvar as armas de todos os players em 1 sу file eu aconselho a usar SII, se vc quiser eu faзo pra vc.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)