PDA

View Full Version : Nine errors and 1 warning


Raphy
14/07/2012, 09:48 AM
Hello, I added the command "tempban" the system in system admin admin LuxAdmin ladmin4v2 and gives me some errors that do not know how to solve them.

G:\Server\filterscripts\ladmin4v2.pwn(2910) : error 017: undefined symbol "cmdtext"
G:\Server\filterscripts\ladmin4v2.pwn(2920) : error 017: undefined symbol "cmdtext"
G:\Server\filterscripts\ladmin4v2.pwn(2935) : error 017: undefined symbol "strtok2"
G:\Server\filterscripts\ladmin4v2.pwn(2935) : error 033: array must be indexed (variable "reason")
G:\Server\filterscripts\ladmin4v2.pwn(2952) : error 017: undefined symbol "IsMonth31"
G:\Server\filterscripts\ladmin4v2.pwn(2965) : error 017: undefined symbol "IsMonth31"
G:\Server\filterscripts\ladmin4v2.pwn(2978) : error 017: undefined symbol "IsMonth31"
G:\Server\filterscripts\ladmin4v2.pwn(2991) : error 017: undefined symbol "IsMonth31"
G:\Server\filterscripts\ladmin4v2.pwn(3013) : error 004: function "SaveIn" is not implemented
G:\Server\filterscripts\ladmin4v2.pwn(2902) : warning 203: symbol is never used: "params"

dcmd_tempban(playerid, params[])
{
new string[128], tmp[256];
new name[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
// new giveplayerid;
if(PlayerInfo[playerid][Level] >= 4)
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
SendClientMessage(playerid, orange, "Function: Temporarily bans a player for specified Days");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
SendClientMessage(playerid, orange, "Function: Temporarily bans a player for specified Days");
return 1;
}
new days = strval(tmp);
if(!IsNumeric(tmp))
return SendClientMessage(playerid, lightred, "ERROR: Invalid Day! Only Numbers!");

if(strval(tmp) <= 0 || strval(tmp) > 1000)
return SendClientMessage(playerid, lightred, "ERROR: Invalid Day! (1-1000)");

new reason[128];
reason = strtok2(cmdtext,idx);
if (!strlen(reason))
return SendClientMessage(playerid, lightred, "ERROR: Reason not Specified!");

if (strlen(reason) <= 0 || strlen(reason) > 100)
return SendClientMessage(playerid, lightred, "ERROR: Invalid Reason length!");

new ip[15];
GetPlayerIp(giveplayerid,ip,15);
GetPlayerName(playerid, name, sizeof name);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new File:tempban = fopen("LuxAdmin/Config/TempBans.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, "%d|%d|%d|%s\n", day, month, year, ip);
fwrite(tempban, string);
fclose(tempban);
}
format(string,128,"|- Administrator %s Temporarily Banned %s for %d Day(s) | Reason: %s -|",name,giveplayer,days,reason);
SendClientMessageToAll(lightred,string);
Kick(giveplayerid);

format(string, sizeof string, "Admin %s Temporarily Banned %s for %d Day(s) | Reason: %s",name,giveplayer,days,reason);
SaveIn("TempBansLog",string);
}
else
{
ErrorMessages(playerid, 2);
}
}
else return ErrorMessages(playerid, 1);
return true;
}

Please help me, thanks.

clarencecuzz
14/07/2012, 10:00 AM
Replace tmp with this.tmp = strtok(params,Index);

stock IsMonth31(month) //Add this to the bottom of your script.
{
new year, month, day;
getdate(year, month, day);
if(month == 4 || month == 6 || month == 9 || month == 1) return true;
return false;
}

clarencecuzz
14/07/2012, 10:02 AM
dcmd_tempban(playerid, params[])
{
new string[128], tmp[256], tmp2[256], tmp3[256];
new name[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new idx;
// new giveplayerid;
if(PlayerInfo[playerid][Level] >= 4)
{
tmp = strtok(params,idx);
tmp2 = strtok(params,idx);
tmp3 = strtok(params,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
SendClientMessage(playerid, orange, "Function: Temporarily bans a player for specified Days");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if (!strlen(tmp) || !strlen(tmp2) || !strlen(tmp3))
{
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /tempban [PlayerID] [Day(s)] [Reason]");
SendClientMessage(playerid, orange, "Function: Temporarily bans a player for specified Days");
return 1;
}
new days = strval(tmp2);
if(!IsNumeric(tmp))
return SendClientMessage(playerid, lightred, "ERROR: Invalid Day! Only Numbers!");

if(strval(tmp) <= 0 || strval(tmp) > 1000)
return SendClientMessage(playerid, lightred, "ERROR: Invalid Day! (1-1000)");

new reason[128];
reason = strval(tmp3);
if (!strlen(reason))
return SendClientMessage(playerid, lightred, "ERROR: Reason not Specified!");

if (strlen(reason) <= 0 || strlen(reason) > 100)
return SendClientMessage(playerid, lightred, "ERROR: Invalid Reason length!");

new ip[15];
GetPlayerIp(giveplayerid,ip,15);
GetPlayerName(playerid, name, sizeof name);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new File:tempban = fopen("LuxAdmin/Config/TempBans.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, "%d|%d|%d|%s\n", day, month, year, ip);
fwrite(tempban, string);
fclose(tempban);
}
format(string,128,"|- Administrator %s Temporarily Banned %s for %d Day(s) | Reason: %s -|",name,giveplayer,days,reason);
SendClientMessageToAll(lightred,string);
Kick(giveplayerid);

format(string, sizeof string, "Admin %s Temporarily Banned %s for %d Day(s) | Reason: %s",name,giveplayer,days,reason);
SaveIn("TempBansLog",string);
}
else
{
ErrorMessages(playerid, 2);
}
}
else return ErrorMessages(playerid, 1);
return true;
}

EDIT: Sorry for the double post, I was meant to edit my original post.

Raphy
14/07/2012, 10:25 AM
I put that script and now gives me 7 errors

G:\Server\filterscripts\ladmin4v2.pwn(2904) : warning 219: local variable "month" shadows a variable at a preceding level
G:\Server\filterscripts\ladmin4v2.pwn(2902) : warning 203: symbol is never used: "month"
G:\Server\filterscripts\ladmin4v2.pwn(2918) : error 017: undefined symbol "cmdtext"
G:\Server\filterscripts\ladmin4v2.pwn(2928) : error 017: undefined symbol "cmdtext"
G:\Server\filterscripts\ladmin4v2.pwn(2943) : error 017: undefined symbol "strtok2"
G:\Server\filterscripts\ladmin4v2.pwn(2943) : error 033: array must be indexed (variable "reason")
G:\Server\filterscripts\ladmin4v2.pwn(2986) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(2999) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(3021) : error 004: function "SaveIn" is not implemented
G:\Server\filterscripts\ladmin4v2.pwn(2910) : warning 203: symbol is never used: "params"

Raphy
14/07/2012, 12:58 PM
Please excuse me for double post but someone help me?

[MM]RoXoR[FS]
14/07/2012, 01:47 PM
Replace Every cmdtext with params.
Replace strtok2 with strtok

Raphy
14/07/2012, 02:00 PM
We replaced strtock2 with strtock and went, I replaced the params cmdtext and I give these 3 warning.

G:\Server\filterscripts\ladmin4v2.pwn(2918) : warning 202: number of arguments does not match definition
G:\Server\filterscripts\ladmin4v2.pwn(2928) : warning 202: number of arguments does not match definition
G:\Server\filterscripts\ladmin4v2.pwn(2943) : warning 202: number of arguments does not match definition

If you help me and other errors and warnings please?

G:\Server\filterscripts\ladmin4v2.pwn(2904) : warning 219: local variable "month" shadows a variable at a preceding level
G:\Server\filterscripts\ladmin4v2.pwn(2902) : warning 203: symbol is never used: "month"
G:\Server\filterscripts\ladmin4v2.pwn(2943) : error 047: array sizes do not match, or destination array is too small
G:\Server\filterscripts\ladmin4v2.pwn(2986) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(2999) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(3021) : error 004: function "SaveIn" is not implemented

clarencecuzz
14/07/2012, 02:05 PM
Show lines 2918, 2928 and 2943.

Raphy
14/07/2012, 02:32 PM
Line 2918:
tmp = strtok(params);
Line 2928:
tmp = strtok(params);
Line 2943:
reason = strtok(params);

These are lines

clarencecuzz
14/07/2012, 02:54 PM
Change to strtok(params,idx);

Raphy
14/07/2012, 03:00 PM
Yes and I say this:

G:\Server\filterscripts\ladmin4v2.pwn(2918) : error 017: undefined symbol "idx"
G:\Server\filterscripts\ladmin4v2.pwn(2928) : error 017: undefined symbol "idx"
G:\Server\filterscripts\ladmin4v2.pwn(2943) : error 017: undefined symbol "idx"

clarencecuzz
14/07/2012, 03:11 PM
Add new idx; just above all the strtok(params,idx) lines.

Raphy
14/07/2012, 03:25 PM
Thank you very much clarencecuzz but if you please help me and the rest of the errors? As'm not very good thank you :)
G:\Server\filterscripts\ladmin4v2.pwn(2904) : warning 219: local variable "month" shadows a variable at a preceding level
G:\Server\filterscripts\ladmin4v2.pwn(2902) : warning 203: symbol is never used: "month"
G:\Server\filterscripts\ladmin4v2.pwn(2944) : error 047: array sizes do not match, or destination array is too small
G:\Server\filterscripts\ladmin4v2.pwn(2987) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(3000) : error 017: undefined symbol "IsMonth29"
G:\Server\filterscripts\ladmin4v2.pwn(3022) : error 004: function "SaveIn" is not implemented

Line 2904:
new year, month, day;
Line 2902:
stock IsMonth31(month)
Line 2944:
reason = strtok(params,idx);
Line 2987:
else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
Line 3000:
else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
Line 3022:
SaveIn("TempBansLog",string);

Raphy
14/07/2012, 04:36 PM
Please excuse me again for double post but please help me fix these errors and warnings? Please I need now.

Raphy
15/07/2012, 03:57 AM
Someone help me please?

EDIT: It's been 24 hours and I know that after 24 hours may be doing another post and does not count as double post.