23.04.2014, 00:46
Greetings!
I have one command and trouble with her, command function is to give a donate rank to player, all parameter is good, but parameter with level of rank is bugged.
Parameters of command is: ID, donate days, level. This parameter level is bugged
Here you a command:
I have one command and trouble with her, command function is to give a donate rank to player, all parameter is good, but parameter with level of rank is bugged.
Parameters of command is: ID, donate days, level. This parameter level is bugged
Here you a command:
pawn Код:
if(strcmp(cmd, "/givedonate", true) == 0)
{
new name[MAX_PLAYER_NAME];
new level;
if(PlayerInfo[playerid][pAdmin] >= 1)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "Usage: /givedonate [ID] [expired day's] [donate level(1-4)]");
SendClientMessage(playerid, COLOR_GREY, "Function: Temporarily give a donate to player for specified days.");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
level = strval(tmp);
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "Usage: /givedonate [ID] [expired day's] [donate level(1-4)]");
SendClientMessage(playerid, COLOR_GREY, "Function: Temporarily give a donate to player for specified days.");
return 1;
}
new days = strval(tmp);
if(!IsNumeric(tmp))
return SendClientMessage(playerid, COLOR_GREY, "ERROR: Invalid Day! Only Numbers!");
if(strval(tmp) <= 0 || strval(tmp) > 20)
return SendClientMessage(playerid, COLOR_GREY, "ERROR: Invalid Day! (1-20)");
GetPlayerName(playerid, name, sizeof name);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new File:tempban = fopen("Snich_Donatori/Donatori.ban", io_append);
if (tempban)
{
new year,month,day;
getdate(year, month, day);
day += days;
if (IsMonth31(month))
{
if (day > 31)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 31) day -= 31;
}
else while(day > 31) day -= 31;
}
}
else if (!IsMonth31(month))
{
if (day > 30)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 30) day -= 30;
}
else while(day > 30) day -= 30;
}
}
else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
{
if (day > 29)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 29) day -= 29;
}
else while(day > 29) day -= 29;
}
}
else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
{
if (day > 28)
{
month += 1;
if (month > 12)
{
year += 1;
while(day > 28) day -= 28;
}
else while(day > 28) day -= 28;
}
}
format(string, sizeof string, "Ime i prezime: %s. Datum isteka paketa: %d/%d/%d.\n", giveplayer, day, month, year);
fwrite(tempban, string);
fclose(tempban);
}
new y,m,d;
getdate(y,m,d);
if(level <= 0 && level > 4) return SendClientMessage(playerid, COLOR_GREY,"Donate Level ne moze biti manji od 0 niti veci od 4!");
PlayerInfo[giveplayerid][pDonateRank] = level;
format(string,128,"AdmCmd: %s give a donate %s for %d day. Donate level: %d",name,giveplayer,days,level);
SendClientMessageToAll(COLOR_LIGHTRED,string);
PlayerBanned[playerid] = -1;
SetTimerEx("Provjera", 180000, 0, "d", playerid);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "That player is offline!");
}
}
else return SendClientMessage(playerid,COLOR_GRAD1,"You are not authorized to use that command!");
return true;
}