[Ajuda] Retirar arma
#1

Ae pessoal queria que quando ele entrasse na DP fosse retirado as armas que ele estб, e quandoo fosse sair denovo voltasse a arma que ele tava anteriormente...

pawn Код:
if(pickupid == EntrarDP)
    {
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк entrou no Departamento de Polнcia de Fort Carson, tenha muito respeito dentro do mesmo!");
    GameTextForPlayer(playerid, "~b~DP", 3000, 6);
    SetPlayerPos(playerid,322.0163,304.4047,999.1484);
    SetPlayerInterior(playerid,5);
    }
    if(pickupid == SairDP)
    {
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк saiu do Departamento de Polнcia de Fort Carson!");
    SetPlayerPos(playerid,-213.9483,979.2734,19.3348);
    SetPlayerInterior(playerid,0);
    }
Reply
#2

nгo sei seta certo mais tente

pawn Код:
public OnPlayerInteriorChange(playerid,newinteriorid,oldi nteriorid)
{
if(newinteriorid && !oldinteriorid)
{
for(new i = 0; i < 13; i ++)
{
GetPlayerWeaponData(playerid, i, Armas[playerid][i], Ammo[playerid][i]);
}
new reset;
SetPVarInt(playerid, "Armas", 1);
ResetPlayerWeapons(playerid);
reset = SetTimerEx("resetar", 1000, true, "d", playerid);
SendClientMessage(playerid, 0xFFFF00FF, "Suas armas foram retiradas, pois nгo й permitido usб-las em interior. Quando vocк sair, elas serгo devolvidas.");
}
else if(!newinteriorid)
{
if((GetPVarInt(playerid, "Armas")) && (!GetPVarInt(playerid, "Weapons")))
{
for(new i = 0; i < 13; i ++)
GivePlayerWeapon(playerid, Armas[playerid][i], Ammo[playerid][i]);
DeletePVar(playerid, "Armas");
KillTimer("reset");
SendClientMessage(playerid, 0xFFFF00FF, "Suas armas foram reentregues.");
}
DeletePVar(playerid, "Weapons");
}
return 1;
}
Reply
#3

Testah aew, Avisa se funcionou Aki Manin '-'

pawn Код:
if(pickupid == EntrarDP)
    {
    SaveWeapons(playerid); // ADICIONADO
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк entrou no Departamento de Polнcia de Fort Carson,   tenha muito respeito dentro do mesmo!");
    GameTextForPlayer(playerid, "~b~DP", 3000, 6);
    SetPlayerPos(playerid,322.0163,304.4047,999.1484);
    SetPlayerInterior(playerid,5);
    ResetPlayerWeapons(playerid); // ADICIONADO
    }
    if(pickupid == SairDP)
    {
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк saiu do Departamento de  Polнcia de Fort Carson!");
    SetPlayerPos(playerid,-213.9483,979.2734,19.3348);
    SetPlayerInterior(playerid,0);
    LoadWeapons(playerid); // ADICIONADO
    }



stock SaveWeapons(playerid)  // ADICIONADO
{
    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;
}


stock LoadWeapons(playerid)  // ADICIONADO
{
    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;
}
Em Caso de Dъvidas manda Msg por Privado ^_^
Reply
#4

me ajuda aqui clerison ?

https://sampforum.blast.hk/showthread.php?tid=441357
Reply
#5

Quote:
Originally Posted by VivendoVirtual
Посмотреть сообщение
Testah aew, Avisa se funcionou Aki Manin '-'

pawn Код:
if(pickupid == EntrarDP)
    {
    SaveWeapons(playerid); // ADICIONADO
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк entrou no Departamento de Polнcia de Fort Carson,   tenha muito respeito dentro do mesmo!");
    GameTextForPlayer(playerid, "~b~DP", 3000, 6);
    SetPlayerPos(playerid,322.0163,304.4047,999.1484);
    SetPlayerInterior(playerid,5);
    ResetPlayerWeapons(playerid); // ADICIONADO
    }
    if(pickupid == SairDP)
    {
    SendClientMessage(playerid, 0xBCD2EEAA,"(INFO) Vocк saiu do Departamento de  Polнcia de Fort Carson!");
    SetPlayerPos(playerid,-213.9483,979.2734,19.3348);
    SetPlayerInterior(playerid,0);
    LoadWeapons(playerid); // ADICIONADO
    }



stock SaveWeapons(playerid)  // ADICIONADO
{
    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;
}


stock LoadWeapons(playerid)  // ADICIONADO
{
    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;
}
Em Caso de Dъvidas manda Msg por Privado ^_^
Код:
.pwn(1035) : error 017: undefined symbol "WEAPON_FILE"
.pwn(1036) : error 017: undefined symbol "WEAPON_FILE"
.pwn(1036) : warning 215: expression has no effect
.pwn(1036) : warning 215: expression has no effect
.pwn(1036) : error 001: expected token: ";", but found ")"
.pwn(1036) : error 029: invalid expression, assumed zero
.pwn(1036) : fatal error 107: too many error messages on one line
Reply
#6

tenta aquilo que eu te passei
Reply
#7

Quote:
Originally Posted by Cromado
Посмотреть сообщение
tenta aquilo que eu te passei
Nem deu man ;/
Reply
#8

pawn Код:
#define WEAPON_FILE  "armas.cfg"
poste as linhas do erros

Em Caso de Dъvidas manda Msg por Privado ^_^
Reply
#9

Quote:
Originally Posted by VivendoVirtual
Посмотреть сообщение
pawn Код:
#define WEAPON_FILE  "armas.cfg"
LoL

Код:
off = strtok(tmp, index);
new off[256], index;


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));
Код:
.pwn(1043) : error 017: undefined symbol "strtok"
.pwn(1043) : error 033: array must be indexed (variable "off")
.pwn(1042) : warning 203: symbol is never used: "index"
.pwn(1090) : error 017: undefined symbol "strtok"
.pwn(1090) : error 033: array must be indexed (variable "off")
.pwn(1093) : error 017: undefined symbol "strtok"
.pwn(1094) : error 017: undefined symbol "strtok"
.pwn(1089) : warning 203: symbol is never used: "index"
Reply
#10

Tendo a chance de aprender a fazer , use a logica e uma ajuda da wiki sa-mp.
https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
https://sampwiki.blast.hk/wiki/GivePlayerWeapon
https://sampwiki.blast.hk/wiki/ResetPlayerWeapons
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)