sscanf Error! -
danish007 - 07.01.2015
hello i've this error
pawn Код:
[09:09:21] sscanf warning: Strings without a length are deprecated, please add a destination size.
and when using command /disable it give me unknown command..
please help me
pawn Код:
COMMAND:disable(playerid, params[])
{
new TargetID, string[256], Reason[100], Days;
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(PlayerInfo[playerid][pAdminlevel] > 0)
{
if(sscanf(params, "uds", TargetID, Days, Reason))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /disable (Name/ID) (Days) (Reason])");
return 1;
}
if(!IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
return 1;
}
if(PlayerInfo[playerid][pAdminlevel] < 2 && PlayerInfo[TargetID][pAdminlevel] > 0)
{
format(string, sizeof(string), "%s (%d) is Server Admin, Can Not Be Attacked.",PlayerInfo[TargetID][pName],TargetID);
SendClientMessage(playerid,COLOR_ERROR, string);
return 1;
}
if(IsPlayerNPC(TargetID))
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Disable a BOT Account.");
return 1;
}
new Exp = gettime()+(60*60*24*Days);
new INI:File = INI_Open(UserDisablePath(TargetID));
INI_SetTag(File,"Data");
INI_WriteInt(File,"DisableExp",Exp);
INI_WriteString(File,"DisabledBy",PlayerInfo[playerid][pName]);
INI_WriteString(File,"Reason",Reason);
INI_Close(File);
new File:logg = fopen("DisabledPlayers.txt",io_append);
fwrite(logg, PlayerInfo[TargetID][pName]);
fwrite(logg,"\n");
fclose(logg);
format(string, sizeof(string), "An Adminstrator Has Disabled Your Account For %i Days. Reason: %s",Days,Reason);
SendClientMessage(TargetID,COLOR_ADMIN, string);
format(string, sizeof(string), "***KICK: %s (%d) Has Been Disabled By An Admin For %i Days. Reason: %s",PlayerInfo[TargetID][pName], TargetID, Days, Reason);
SendClientMessageToAll(COLOR_ADMIN, string);
KickEx(TargetID);
}else{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
}
}else{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
}
return 1;
}
Respuesta: sscanf Error! -
JuanStone - 07.01.2015
Change:
pawn Код:
if(sscanf(params, "uds", TargetID, Days, Reason))
by:
pawn Код:
if(sscanf(params, "uds[100]", TargetID, Days, Reason))
Re: sscanf Error! -
danish007 - 07.01.2015
not works
Re: sscanf Error! -
danish007 - 07.01.2015
please help me
Respuesta: sscanf Error! -
JuanStone - 07.01.2015
pawn Код:
COMMAND:disable(playerid, params[])
{
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(PlayerInfo[playerid][pAdminlevel] >= 1)
{
new reason[100];
if(sscanf(params, "uis[100]", params[0], params[1], reason)) return SendClientMessage(playerid, -1, "Usage: /disable [playerid/name] [days] [reason]");
if(IsPlayerConnected(params[0]) && params[0] != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pAdminlevel] > PlayerInfo[params[0]][pAdminlevel])
{
if(!IsPlayerNPC(params[0]))
{
new Exp = gettime()+(60*60*24*Days);
new INI:File = INI_Open(UserDisablePath(params[0]));
INI_SetTag(File,"Data");
INI_WriteInt(File,"DisableExp", Exp);
INI_WriteString(File,"DisabledBy",PlayerInfo[playerid][pName]);
INI_WriteString(File,"Reason", Reason);
INI_Close(File);
new File:logg = fopen("DisabledPlayers.txt",io_append);
fwrite(logg, PlayerInfo[params[0]][pName]);
fwrite(logg,"\n");
fclose(logg);
format(string, sizeof(string), "An Adminstrator Has Disabled Your Account For %i Days. Reason: %s", params[1], Reason);
SendClientMessage(params[0], COLOR_ADMIN, string);
format(string, sizeof(string), "***KICK: %s (%d) Has Been Disabled By An Admin For %i Days. Reason: %s",PlayerInfo[params[0]][pName], params[0], params[1], Reason);
SendClientMessageToAll(COLOR_ADMIN, string);
KickEx(params[0]);
}
else
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Disable a BOT Account.");
}
}
else
{
format(string, sizeof(string), "%s (%d) is Server Admin, Can Not Be Attacked.",PlayerInfo[params[0]][pName], params[0]);
SendClientMessage(playerid, COLOR_ERROR, string);
}
}
else
{
SendClientMessage(playerid, -1, "Player no conected.");
}
}
else
{
SendClientMessage(playerid, -1, "You are not administrator.");
}
}
else
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
}
return true;
}
Re: sscanf Error! -
danish007 - 07.01.2015
now no any error in serverlog.. but its says unknown command.
Re: sscanf Error! -
Sid_Alexander - 07.01.2015
pawn Код:
COMMAND:disable(playerid, params[])
{
new TargetID, string[128], Reason[100], Days;
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(PlayerInfo[playerid][pAdminlevel] > 0)
{
if(sscanf(params, "uds", TargetID, Days, Reason))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /disable (Name/ID) (Days) (Reason])");
return 1;
}
if(!IsPlayerConnected(TargetID) || TargetID == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
return 1;
}
if(PlayerInfo[playerid][pAdminlevel] < 2 && PlayerInfo[TargetID][pAdminlevel] > 0)
{
format(string, sizeof(string), "%s (%d) is Server Admin, Can Not Be Attacked.",PlayerInfo[TargetID][pName],TargetID);
SendClientMessage(playerid,COLOR_ERROR, string);
return 1;
}
if(IsPlayerNPC(TargetID))
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Disable a BOT Account.");
return 1;
}
new Exp = gettime()+(60*60*24*Days);
new INI:File = INI_Open(UserDisablePath(TargetID));
INI_SetTag(File,"Data");
INI_WriteInt(File,"DisableExp",Exp);
INI_WriteString(File,"DisabledBy",PlayerInfo[playerid][pName]);
INI_WriteString(File,"Reason",Reason);
INI_Close(File);
new File:logg = fopen("DisabledPlayers.txt",io_append);
fwrite(logg, PlayerInfo[TargetID][pName]);
fwrite(logg,"\n");
fclose(logg);
format(string, sizeof(string), "An Adminstrator Has Disabled Your Account For %i Days. Reason: %s",Days,Reason);
SendClientMessage(TargetID,COLOR_ADMIN, string);
format(string, sizeof(string), "***KICK: %s (%d) Has Been Disabled By An Admin For %i Days. Reason: %s",PlayerInfo[TargetID][pName], TargetID, Days, Reason);
SendClientMessageToAll(COLOR_ADMIN, string);
KickEx(TargetID);
}else{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
}
}else{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
}
return 1;
}
Respuesta: sscanf Error! -
JuanStone - 07.01.2015
What you can assure me that the only problem is in your command ?.
pawn Код:
COMMAND:disable(playerid, params[])
{
new string[256], Reason[100];
if(PlayerInfo[playerid][pSpawned] == 1)
{
if(PlayerInfo[playerid][pAdminlevel] > 0)
{
if(sscanf(params, "uds[100]", params[0], params[1], Reason))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /disable (Name/ID) (days) (Reason])");
return true;
}
if(!IsPlayerConnected(params[0]) || params[0] == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, COLOR_ERROR, "That Player Is Not Connected.");
return true;
}
if(PlayerInfo[playerid][pAdminlevel] < 2 && PlayerInfo[params[0]][pAdminlevel] > 0)
{
format(string, sizeof(string), "%s (%d) is Server Admin, Can Not Be Attacked.",PlayerInfo[params[0]][pName],params[0]);
SendClientMessage(playerid,COLOR_ERROR, string);
return true;
}
if(IsPlayerNPC(params[0]))
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Disable a BOT Account.");
return true;
}
new Exp = gettime()+(60*60*24*params[1]);
new INI:File = INI_Open(UserDisablePath(params[0]));
INI_SetTag(File,"Data");
INI_WriteInt(File,"DisableExp",Exp);
INI_WriteString(File,"DisabledBy",PlayerInfo[playerid][pName]);
INI_WriteString(File,"Reason",Reason);
INI_Close(File);
new File:logg = fopen("DisabledPlayers.txt",io_append);
fwrite(logg, PlayerInfo[params[0]][pName]);
fwrite(logg,"\n");
fclose(logg);
format(string, sizeof(string), "An Adminstrator Has Disabled Your Account For %i days. Reason: %s",params[1],Reason);
SendClientMessage(params[0],COLOR_ADMIN, string);
format(string, sizeof(string), "***KICK: %s (%d) Has Been Disabled By An Admin For %i days. Reason: %s",PlayerInfo[params[0]][pName], params[0], params[1], Reason);
SendClientMessageToAll(COLOR_ADMIN, string);
KickEx(params[0]);
}
else
{
SendClientMessage(playerid,COLOR_ERROR,""ERROR_MSG"");
}
}
else
{
SendClientMessage(playerid,COLOR_ERROR,"You Cannot Use This Command While You're Dead.");
}
return 1;
}
Re: sscanf Error! -
danish007 - 07.01.2015
because it happen when i use only this command.
Re: sscanf Error! -
danish007 - 07.01.2015
ok guyzz i got the problem when i use this in command,
pawn Код:
new INI:File = INI_Open(UserDisablePath(TargetID));
INI_SetTag(File,"Data");
INI_WriteInt(File,"DisableExp",Exp);
INI_WriteString(File,"DisabledBy",PlayerInfo[playerid][pName]);
INI_WriteString(File,"Reason",Reason);
INI_Close(File);
it says to me unknown command.
when i remove this and again check command it works fine so please tell me now what ihave to do?
b/c i cannot use command with this code i need to save player data