sscanf error [ need help ]
#1

Guys i am wondering what happen
i already changed the codes for like million times
but still sscanf wont work for me

can you help me?

bdw here is the code

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new id,level[40],string1[500],string2[500];
    //if(!IsPlayerAdmin(playerid) || pData[playerid][pAdmin] < 6) return Errorcmd(playerid);
    if(sscanf(params,"us[40]",id,level)) return SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/Id ] [ Traine / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Player Not Connected [ Unknown Player ]");
    if(!strfind(level,"tra"))
    {
       pData[id][pAdmin] = 1;
    }
    else if(!strfind(level,"mod"))
    {
       pData[id][pAdmin] = 2;
    }
    else if(!strfind(level,"head mod"))
    {
      pData[id][pAdmin] = 3;
    }
    else if(!strfind(level,"admin"))
    {
      pData[id][pAdmin] = 4;
    }
    else if(!strfind(level,"head admin"))
    {
      pData[id][pAdmin] = 5;
    }
    else if(!strfind(level,"manager"))
    {
       pData[id][pAdmin] = 6;
    }
    else
    {
        SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/Id ] [ Traine / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
        return 1;
    }
    //if(level == 0) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Level must range at 0 to 6");
    //pData[id][pAdmin] = level;
    format(string1,sizeof(string1),""CSERVER"%s:"CWHITE" You have been promoted to [ %s ] by [ "CGREEN"%s"CWHITE" ]",fData[BotName],alevel(playerid),pRPName(playerid));
    SendClientMessage(id,C_WHITE,string1);
    format(string2,sizeof(string2),""CSERVER"%s:"CWHITE" You have promoted %s to a [ %s ] status",fData[BotName],pRPName(id),alevel(playerid));
    SendClientMessage(playerid,C_WHITE,string2);
    return 1;
}
Reply
#2

How does it "not work"? Explain the problem so people know what they need to look for.
Reply
#3

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
How does it "not work"? Explain the problem so people know what they need to look for.
When i use the command /makeadmin
without the id and the string

the [USAGE: /makeadmin [ name/id ] [ blah blah blah ]
wont work
and also

it wont send message
when i enter the unknown strfind string
Reply
#4

Did you try uisng the strcmp method?

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new id,level[40],string1[124],string2[124];
    if(!IsPlayerAdmin(playerid) || pData[playerid][pAdmin] == 0) return Errorcmd(playerid);
    if(sscanf(params,"us[40]",id,level)) return SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/Id ] [ Traine / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Player Not Connected [ Unknown Player ]");
    if(!strcmp(level, "trainee", true) == 0)
    {
        pData[id][pAdmin] = 1;
    }
    if(!strcmp(level, "mod", true) == 0)
    {
        pData[id][pAdmin] = 2;
    }  
    if(!strcmp(level, "headmod", true) == 0)
    {
        pData[id][pAdmin] = 3;
    }  
    if(!strcmp(level, "admin", true) == 0)
    {
        pData[id][pAdmin] = 4;
    }  
    if(!strcmp(level, "headadmin", true) == 0)
    {
        pData[id][pAdmin] = 5;
    }  
    if(!strcmp(level, "manager", true) == 0)
    {
        pData[id][pAdmin] = 6;
    }      
    else
    {
        SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/ID ] [ Trainee / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
        return 1;
    }
    //if(level == 0) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Level must range at 0 to 6");
    //pData[id][pAdmin] = level;
    format(string1,sizeof(string1),""CSERVER"%s:"CWHITE" You have been promoted to [ %s ] by [ "CGREEN"%s"CWHITE" ]",fData[BotName],alevel(playerid),pRPName(playerid));
    SendClientMessage(id,C_WHITE,string1);
    format(string2,sizeof(string2),""CSERVER"%s:"CWHITE" You have promoted %s to a [ %s ] status",fData[BotName],pRPName(id),alevel(playerid));
    SendClientMessage(playerid,C_WHITE,string2);
    return 1;
}
I think this should work.

EDIT: I didnt test that because I couldnt, as there some stuff required for me to test, so my guess is that should work.
Reply
#5

Quote:
Originally Posted by Riddy
Посмотреть сообщение
Did you try uisng the strcmp method?

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new id,level[40],string1[124],string2[124];
    if(!IsPlayerAdmin(playerid) || pData[playerid][pAdmin] == 0) return Errorcmd(playerid);
    if(sscanf(params,"us[40]",id,level)) return SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/Id ] [ Traine / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Player Not Connected [ Unknown Player ]");
    if(!strcmp(level, "trainee", true) == 0)
    {
        pData[id][pAdmin] = 1;
    }
    if(!strcmp(level, "mod", true) == 0)
    {
        pData[id][pAdmin] = 2;
    }  
    if(!strcmp(level, "headmod", true) == 0)
    {
        pData[id][pAdmin] = 3;
    }  
    if(!strcmp(level, "admin", true) == 0)
    {
        pData[id][pAdmin] = 4;
    }  
    if(!strcmp(level, "headadmin", true) == 0)
    {
        pData[id][pAdmin] = 5;
    }  
    if(!strcmp(level, "manager", true) == 0)
    {
        pData[id][pAdmin] = 6;
    }      
    else
    {
        SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/ID ] [ Trainee / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
        return 1;
    }
    //if(level == 0) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Level must range at 0 to 6");
    //pData[id][pAdmin] = level;
    format(string1,sizeof(string1),""CSERVER"%s:"CWHITE" You have been promoted to [ %s ] by [ "CGREEN"%s"CWHITE" ]",fData[BotName],alevel(playerid),pRPName(playerid));
    SendClientMessage(id,C_WHITE,string1);
    format(string2,sizeof(string2),""CSERVER"%s:"CWHITE" You have promoted %s to a [ %s ] status",fData[BotName],pRPName(id),alevel(playerid));
    SendClientMessage(playerid,C_WHITE,string2);
    return 1;
}
I think this should work.

EDIT: I didnt test that because I couldnt, as there some stuff required for me to test, so my guess is that should work.
Yes i have tried it but still wont work
i even remove the strfind method and leave nothing
and still nothing will appear
Reply
#6

Код:
CMD:makeadmin(playerid,params[])
{
	new id,level[40],string1[124],string2[124];
	if(!IsPlayerAdmin(playerid) || pData[playerid][pAdmin] == 0) return Errorcmd(playerid);
	if(sscanf(params,"us[40]",id,level)) return SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/Id ] [ Traine / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Player Not Connected [ Unknown Player ]");
	if(strcmp(level, "tra", true) == 0)
	{
		pData[id][pAdmin] = 1;
	}
	if(strcmp(level, "mod", true) == 0)
	{
		pData[id][pAdmin] = 2;
	}
	if(strcmp(level, "headmod", true) == 0)
	{
		pData[id][pAdmin] = 3;
	}
	if(strcmp(level, "admin", true) == 0)
	{
		pData[id][pAdmin] = 4;
	}
	if(strcmp(level, "headadmin", true) == 0)
	{
		pData[id][pAdmin] = 5;
	}
	if(strcmp(level, "manager", true) == 0)
	{
		pData[id][pAdmin] = 6;
	}
	else
	{
 	   	SendClientMessage(playerid,C_WHITE,""CUSAGE"[USAGE]:"CWHITE" /makeadmin [ Name/ID ] [ Trainee / "CMOD"Moderator"CWHITE" / "CHMOD"Head Moderator"CWHITE" / "CADMIN"Administrator"CWHITE" / "CHADMIN"Head Andministrator"CWHITE" ]");
        return 1;
	}
	//if(level == 0) return SendClientMessage(playerid,C_RED,"ERROR:"CWHITE" Level must range at 0 to 6");
    //pData[id][pAdmin] = level;
	format(string1,sizeof(string1),""CSERVER"%s:"CWHITE" You have been promoted to [ %s ] by [ "CGREEN"%s"CWHITE" ]",fData[BotName],alevel(playerid),pRPName(playerid));
	SendClientMessage(id,C_WHITE,string1);
	format(string2,sizeof(string2),""CSERVER"%s:"CWHITE" You have promoted %s to a [ %s ] status",fData[BotName],pRPName(id),alevel(playerid));
	SendClientMessage(playerid,C_WHITE,string2);
	return 1;
}
Reply
#7

Ex:
pawn Код:
if(!strcmp(level,"tra"))
   pData[id][pAdmin] = 1;
else if(!strcmp(level,"mod"))
   pData[id][pAdmin] = 2;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)