05.06.2011, 23:40
(
Последний раз редактировалось Shadoww5; 06.06.2011 в 09:03.
)
PHP код:
#include <Dini>
#include <a_samp>
#include <time>
public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[256], idx, cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/fakechat", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new texto[128], id, str[128];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1,"USO: /fakechat [ID] [TEXTO]");
id = strval(tmp);
texto = strtok(cmdtext, idx);
format(str, sizeof(str),"Vocк forзou %d а falar:",id);
SendClientMessage(playerid, -1, str);
format(str, sizeof(str),"%s",texto);
SendClientMessage(playerid, -1, str);
OnPlayerText(id, texto);
}
else return SendClientMessage(playerid, -1, "Vocк nгo estб logado na RCON.");
}
if(strcmp(cmd, "/setaradmin", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new id, level, dia, mes, ano, a, m, d, save[40], n[MAX_PLAYER_NAME];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /setaradmin [ID] [LEVEL] [dia] [mкs] [ano]");
id = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /setaradmin [ID] [LEVEL] [dia] [mкs] [ano]");
level = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /setaradmin [ID] [LEVEL] [dia] [mкs] [ano]");
dia = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /setaradmin [ID] [LEVEL] [dia] [mкs] [ano]");
mes = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /setaradmin [ID] [LEVEL] [dia] [mкs] [ano]");
ano = strval(tmp);
getdate(a, m, d);
if(dia < 1 || dia > 30) return SendClientMessage(playerid, -1, "O dia deve estar entre 1 e 30.");
if(mes < 1 || mes > 12) return SendClientMessage(playerid, -1, "O mкs deve estar entre 1 e 12");
if(mes == 2 && dia > 28) return SendClientMessage(playerid, -1, "Fevereiro sу tem 28 dias !");
if(ano < a) return SendClientMessage(playerid, -1, "O ano deve ser superior ao corrente ano.");
SetPVarInt(id, "ADM", level);
GetPlayerName(id, n, sizeof(n));
format(save, sizeof(save), "/Adms/%s.txt",n);
dini_Set(save, "Dia", dia);
dini_Set(save, "Mes", mes);
dini_Set(save, "Ano", ano);
SendClientMessage(playerid, -1, "Level e tempo setado com sucesso.");
SendClientMessage(id, -1, "Seu level e tempo de adm foram setados com sucesso.");
}
else return SendClientMessage(playerid, -1, "Vocк nгo estб logado na RCON.");
}
return 0;
}
public OnPlayerConnect(playerid)
{
new d, m, a, save[40], n[MAX_PLAYER_NAME];
getdate(a, m, d);
GetPlayerName(playerid, n, sizeof(n));
format(save, sizeof(save),"/Adms/%s.txt",n);
if(dini_Exists(save))
{
if(a == dini_Get(save, "Ano") && m == dini_Get(save, "Mes") && d == dini_Get(save, "Dia"))
{
SetPVarInt(playerid, "ADM", 0);
SendClientMessage(playerid, -1, "Seu tempo de administrador temporбrio esgotou e vocк perdeu o cargo !");
dini_Remove(save);
return 1;
}
return 1;
}
return 1;
}
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;
}