pawno crashes because of sscanf2 -
bijoyekuza - 20.03.2011
hey scripters
this is so annyoing
I want to learn sscanf and dcmd because as i saw its much more better then strtok and much more faster/shorter.
I dont want to use this long command anymore :
Код:
if(strcmp(cmd,"/ban",true) == 0) {
if(PlayerInfo[playerid][pAdminLevel] > 1)
{
new tmp[256],tmp2[256],adminname[MAX_PLAYER_NAME],victim,victimname[MAX_PLAYER_NAME],string[256],string2[256];
tmp = strtok(cmdtext, idx);
tmp2 = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid,COLOR_RED,": Usage : /ban [PLAYERID][REASON]");
if(strlen(tmp2) == 0) return SendClientMessage(playerid,COLOR_RED,": Usage : /ban [PLAYERID][REASON]");
victim = strval(tmp);
if(!IsPlayerConnected(victim))
{
notc(playerid);
}
new Year, Month, Day;
getdate(Year, Month, Day);
GetPlayerName(victim,victimname,sizeof(victimname));
GetPlayerName(playerid,adminname,sizeof(adminname));
format(string,sizeof(string)," You have banned : %s",victimname);
new reason[256];
reason = tmp2;
if(strlen(tmp) == 1) {format(string2,sizeof(string2)," %d/%d/%d Player %s Has been banned by admin : MR.%s . Reason : %s",Year,Month,Day,victimname,adminname,cmdtext[5]);}
if(strlen(tmp) == 2) {format(string2,sizeof(string2)," %d/%d/%d Player %s Has been banned by admin : MR.%s . Reason : %s",Year,Month,Day,victimname,adminname,cmdtext[6]);}
if(IsPlayerConnected(victim))
{
SendClientMessageToAll(COLOR_RED,string2);
Ban(strval(tmp));
}
I just want to make short commands with 10 lines limit
I dont want that just one little ban command will take a full script
so the problem is
whene i #include<sscanf2> in my pawno I get a crash !!!!!!!!!!!!!!!!!!
Re: pawno crashes because of sscanf2 -
aircombat - 20.03.2011
in sscanf2 u need a plugin to make it work which can be found in the .rar file with the include
Re: pawno crashes because of sscanf2 -
Jochemd - 20.03.2011
@ aircombat: That should not cause the crash. This command is just not closed properly with the brackets.
pawn Код:
dcmd_ban(playerid,params[])
{
new adminname[MAX_PLAYER_NAME],victim,victimname[MAX_PLAYER_NAME],string[128],reason[50];
if(!sscanf(params,"us[50]",victim,reason))
{
new Year, Month, Day;
getdate(Year, Month, Day);
GetPlayerName(victim,victimname,sizeof(victimname));
GetPlayerName(playerid,adminname,sizeof(adminname));
format(string,sizeof(string)," You have banned : %s",victimname);
SendClientMessage(playerid,-1,string);
format(string,sizeof(string)," %d/%d/%d Player %s Has been banned by admin : MR.%s . Reason : %s",Year,Month,Day,victimname,adminname,reason);
SendClientMessageToAll(COLOR_RED,string);
Ban(victim);
return 1;
}
else return SendClientMessage(playerid,COLOR_RED,": Usage : /ban [PLAYERID][REASON]");
}
Try this
Re: pawno crashes because of sscanf2 -
bijoyekuza - 20.03.2011
thats only part of my ban command
by ban command is closed perfectly
when i remove the #include<sscanf2> from my script i dont get crash anymore
when i put it back i do have crashes
and yes i have addded the plugin to server.cfg
Re: pawno crashes because of sscanf2 -
Jochemd - 20.03.2011
Try using the sscanf2 which I've attached to this post.
Re: pawno crashes because of sscanf2 -
bijoyekuza - 20.03.2011
@Jochmed still crashes
Re: pawno crashes because of sscanf2 -
PinkFloydLover - 20.03.2011
Try Deleting all the sscanf code out of your script then see if it still crashes.
Re: pawno crashes because of sscanf2 -
Mean - 20.03.2011
Quote:
Originally Posted by Cale
Try Deleting all the sscanf code out of your script then see if it still crashes.
|
Well duh, he only had
#include <sscanf2>.
Re: pawno crashes because of sscanf2 -
Jochemd - 20.03.2011
Quote:
Originally Posted by Mean
Well duh, he only had #include <sscanf2>.
|
He didn't, he also had my code snippet I posted above here ealier...
Re: pawno crashes because of sscanf2 -
Zh3r0 - 20.03.2011
Erm, by "Crash" you mean a "don't sent" error? Or it gave you an error in the log ?...
Re: pawno crashes because of sscanf2 -
pi22031990 - 20.03.2011
You try find "stock sscanf(string[], format[], {Float,_}:...)" on gamemode and delete it.
Re: pawno crashes because of sscanf2 -
bijoyekuza - 20.03.2011
Quote:
Originally Posted by pi22031990
You try find "stock sscanf(string[], format[], {Float,_}:...)" on gamemode and delete it.
|
thanks alot man fixed my problem.