new randtax = 20 + random(50);/aqui
//...
format(wstring, sizeof(wstring), "Impostos: $%d.", randtax);
SendClientMessage(i,COLOR_LIGHTYELLOW2, wstring);
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;
}
Originally Posted by tshadow
Tenho este code aqui que mete os impostos "б sorte"
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;
}
if(!fexist("imposto.ini") {new File:file=fopen("imposto.ini",io_write);fclose(file);}
stock MudarImposto(grana) {
dini_IntSet("imposto.ini","Imposto",grana);
return 1;
}
stock PegarImposto() {
return dini_Int("imposto.ini","Imposto");
}
Comando...
MudarImposto(Quanto vai ser o imposto);
etc...
new imp=PegarImposto();
GivePlayerMoney(...,imp);
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;
}
Originally Posted by tshadow
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; }
SetTimer("Impostovalor",2000,true);
forward Impostovalor()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, _Impostos_[i]);
}
return 1;
}