SA-MP Forums Archive
ZCMD Questions. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ZCMD Questions. (/showthread.php?tid=244809)



ZCMD Questions. - bake_pg - 28.03.2011

Hy everybody.
I am new to ZCMD but I wan't to use it because it looks more simple than "onplayercommand function."

So I wrote a code for a job, something like Truck driver.
Код:
CMD:materijal(playerid, params[])
{
	new carid=GetPlayerVehicleID(playerid);
	new s;
	if(sscanf(params,"i",s)) return SendClientMessage(playerid, COLOR_GRAD2, "UPOTREBA: /materijal [1 ili 2]");
	if(!(IsAPrevoznikCar(carid))) return SendClientMessage(playerid, COLOR_GRAD3, "You are not in right vehicle!");
	else if(s>2) return SendClientMessage(playerid, COLOR_GRAD2, "Not valid choice!");
	if(s==1)
	{
		SetPlayerCheckpoint(playerid, -1060.0957,-593.9825,31.8627,5.0);//cp
		CP[playerid] = 20;
	}
	else if(s==2)
	{
		SetPlayerCheckpoint(playerid, -1060.0957,-593.9825,31.8627,5.0);//cp
		CP[playerid] = 25;
	}
	return 1;
}
So basicly, this code allow you to choose which route to drive. The code works that is not problem.
I have some questions. Can I short(make a smaller) this code or this is apsoloutly correct?
"if(sscanf(params,"i",s))" - sscanf returns 0 at succes?

thank you, and any advice is welcome.


Re: ZCMD Questions. - -Rebel Son- - 28.03.2011

Heres alittle info friend, in your sscanf line, you have i, i stands for integer, Anyways

To make it smaller


pawn Код:
CMD:materijal(playerid, params[])
{
    new carid=GetPlayerVehicleID(playerid);
    new s;
    if(sscanf(params,"i",s)) return SendClientMessage(playerid, COLOR_GRAD2, "UPOTREBA: /materijal [1 ili 2]");
    if(!(IsAPrevoznikCar(carid))) return SendClientMessage(playerid, COLOR_GRAD3, "You are not in right vehicle!");
    else if(s>2) return SendClientMessage(playerid, COLOR_GRAD2, "Not valid choice!");
    if(s==1){
    SetPlayerCheckpoint(playerid, -1060.0957,-593.9825,31.8627,5.0);//cp
    CP[playerid] = 20;
    }else if(s==2){
    SetPlayerCheckpoint(playerid, -1060.0957,-593.9825,31.8627,5.0);//cp
    CP[playerid] = 25;
    }
    return 1;
}