SA-MP Forums Archive
zcmd & sscanf command params not working as it should - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: zcmd & sscanf command params not working as it should (/showthread.php?tid=411940)



zcmd & sscanf command params not working as it should - Explos - 31.01.2013

Код:
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".


Re: zcmd & sscanf command params not working as it should - Scenario - 31.01.2013

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.


Re: zcmd & sscanf command params not working as it should - Threshold - 31.01.2013

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;
}



Re: zcmd & sscanf command params not working as it should - Explos - 31.01.2013

Thank you