zcmd & sscanf command params not working as it should
#1

Код:
CMD:s(playerid, params[]){
	new rezimas[10];
	sscanf(params, "c", rezimas);
	if(!strcmp(rezimas, "ijungti", true)){
		IsvaizdosRinkimas[playerid] = true;
		TogglePlayerControllable(playerid, false);
		SendClientMessage(playerid, GREEN, "Iљvaizdos rinkimas įjungtas.");
	}
	else if(!strcmp(rezimas, "isjungti", true)){
		IsvaizdosRinkimas[playerid] = false;
		TogglePlayerControllable(playerid, true);
		SendClientMessage(playerid, GREEN, "Iљvaizdos rinkimas iљjungtas.");
	}
    return 1;
}
The problem is that the script can't see any difference between param "ijungti" and "isjungti".
Command "/s ijungti" works just fine and "/s isjungti" works as "/s ijungti".
Reply
#2

First if all, remove sscanf from this code as it is unnecessary. Secondly, take a look at your strcmp statements, they are the same. For the second if statement, remove the if and just make it "else". Also replace rezimas with params and it should be fine.
Reply
#3

Not to mention you were using the c sscanf variable rather than the s sscanf variable. (s = string, c = character)

@RealCop the strcmp statements were not the same.

As RealCop228 said, but as a code:
pawn Код:
CMD:s(playerid, params[])
{
    if(isnull(params)) return 1;
    if(!strcmp(params, "ijungti", true))
    {
        IsvaizdosRinkimas[playerid] = true;
        TogglePlayerControllable(playerid, false);
        SendClientMessage(playerid, GREEN, "Išvaizdos rinkimas įjungtas.");
    }
    else if(!strcmp(params, "isjungti", true))
    {
    IsvaizdosRinkimas[playerid] = false;
    TogglePlayerControllable(playerid, true);
        SendClientMessage(playerid, GREEN, "Išvaizdos rinkimas išjungtas.");
    }
    return 1;
}
Reply
#4

Thank you
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)