Resolvido
#1

Tenho este code aqui que mete os impostos "б sorte"
pawn Код:
new randtax = 20 + random(50);/aqui
//...
format(wstring, sizeof(wstring), "Impostos: $%d.", randtax);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
eu queria fazer para um comando que o presidente escolhe-se quanto era, mas nгo consigo guardar.
Reply
#2

Nгo Entendi, Pois bem Tenta Algo Assim:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
 
    if(strcmp(cmd, "/imposto", true) == 0)
    {
        new tmp[128];
        tmp = strtok(cmdtext, idx);
 for(new i = 0; i < MAX_PLAYERS; i++)
{
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Uso do Comando: /imposto [VALOR]");
        GivePlayerMoney(i, strval(tmp));
}
        return 1;
    }
    return 0;
}

Reply
#3

Quote:
Originally Posted by tshadow
Tenho este code aqui que mete os impostos "б sorte"
pawn Код:
new randtax = 20 + random(50);/aqui
//...
format(wstring, sizeof(wstring), "Impostos: $%d.", randtax);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
eu queria fazer para um comando que o presidente escolhe-se quanto era, mas nгo consigo guardar.
imposto й o IVA( o que as pessoas pagam ao governo), o comando ja tenho, o presidente escolhe o valor do imposto, mas quando chego ao jogo outra vez jб nгo estб
Reply
#4

A ъnica maneira agora que me vem а cabeзa й fazer load a partir de um ficheiro.
Reply
#5

Pera , Precisa usar Dini, jб mostro aqui, Agora vou Fazer Temas que estou a ir Mal na Escola

@EDIT: Tenta Esse Code, Usei Algumas Arrays e Diretivas, Bem Simples Olha talvez lhe ajude

pawn Код:
#include <a_samp>
#include <Dini>
new
_Impostos_[MAX_PLAYERS];

#define _StatsFile_ "_Impostos_.txt"

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/imposto", true) == 0)
{

new tmp[128];
tmp = strtok(cmdtext, idx);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Uso do Comando: /imposto [VALOR]");
_Impostos_[i] = dini_Int(_StatsFile_, "Imposto");
GivePlayerMoney(i, -_Impostos_[i]);
SetTimer("Impostovalor",2000,true);
if(!dini_Exists(_StatsFile_))
{
dini_Create(_StatsFile_);
dini_IntSet(_StatsFile_, "Imposto", _Impostos_[i]);
}
}
return 1;
}
return 0;
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}


forward Impostovalor();
public Impostovalor()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, -_Impostos_[i]);
}
return 1;
}
Reply
#6

Tenta isso:

No OnGameModeInit:
pawn Код:
if(!fexist("imposto.ini") {new File:file=fopen("imposto.ini",io_write);fclose(file);}
Agora as stocks:
pawn Код:
stock MudarImposto(grana) {
dini_IntSet("imposto.ini","Imposto",grana);
return 1;
}

stock PegarImposto() {
return dini_Int("imposto.ini","Imposto");
}
Ai vai ser assim:

Comando para mudar imposto:
pawn Код:
Comando...
MudarImposto(Quanto vai ser o imposto);
etc...
Na hora de cobrar:
pawn Код:
new imp=PegarImposto();
GivePlayerMoney(...,imp);
Reply
#7

pawn Код:
public LoadDynamicImposto()
{
    new arrCoords[33][64];
    new strFromFile2[256];
    new File: file = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(DynamicImposto))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, '|');
            strmid(DynamicFactions[idx][Imposto], arrCoords[0], 0, strlen(arrCoords[0]), 255);
            printf("[Imposto:]%d",DynamicFactions[idx][fName],DynamicFactions[idx][fType],idx);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
public SaveDynamicImposto()
{
    new idx;
    new File: file2;
    while (idx < sizeof(DynamicImposto))
    {

        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d\n",
        DynamicFactions[idx][Imposto]);

        if(idx == 0)
        {
            file2 = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_write);
        }
        else
        {
            file2 = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Para nгo aparecer ninguem a dizer que sou preguiзoso, tem jб aqui um avanзo que dei
Reply
#8

Quote:
Originally Posted by tshadow
pawn Код:
public LoadDynamicImposto()
{
    new arrCoords[33][64];
    new strFromFile2[256];
    new File: file = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(DynamicImposto))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, '|');
            strmid(DynamicFactions[idx][Imposto], arrCoords[0], 0, strlen(arrCoords[0]), 255);
            printf("[Imposto:]%d",DynamicFactions[idx][fName],DynamicFactions[idx][fType],idx);
            idx++;
        }
        fclose(file);
    }
    return 1;
}
public SaveDynamicImposto()
{
    new idx;
    new File: file2;
    while (idx < sizeof(DynamicImposto))
    {

        new coordsstring[512];
        format(coordsstring, sizeof(coordsstring), "%d\n",
        DynamicFactions[idx][Imposto]);

        if(idx == 0)
        {
            file2 = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_write);
        }
        else
        {
            file2 = fopen("CRP_Scriptfiles/Factions/Imposto.cfg", io_append);
        }
        fwrite(file2, coordsstring);
        idx++;
        fclose(file2);
    }
    return 1;
}
Para nгo aparecer ninguem a dizer que sou preguiзoso, tem jб aqui um avanзo que dei
Da uma olhada no dini, para ver como й mais facil. =x
Reply
#9

Prefiro assim a sйrio, nгo sei й puxar a quantidade metida no comando
aqui estб a parte do comando fixa do comando
pawn Код:
if(strcmp(cmd, "/imposto", true) ==0)
    {
        if(IsPlayerConnected(playerid))
      {
            if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1)
            {
                if(rank == 1)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[Comando:] /imposto [Montante]");
                        return 1;
                    }
                    new cash;
                    cash = strval(tmp);
                    if(cash < 1 || cash > 999){ SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERRO:] Invalido montante."); return 1; }
Reply
#10

Olha meu EDIT Acima.

Digita /immposto VALOR

Irб Salvar o Valor do Imposto, entгo apуs irб carrega e cobrar cada vez que Digita

/imposto VALOR

Se Quer que Tire grana a Cada tyempo Crie Timer Mais ou Menos Assim
pawn Код:
SetTimer("Impostovalor",2000,true);
forward Impostovalor()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, _Impostos_[i]);
}
return 1;
}
Espero que nгo tenha sido complicado a vocк
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)