SA-MP Forums Archive
Getting strings from commands and printing variables - 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: Getting strings from commands and printing variables (/showthread.php?tid=392116)



Getting strings from commands and printing variables - Dennis_Smith - 12.11.2012

Код:
	if(strcmp("/setplate , cmdtext , true, 30) == 0)
	{
	
	    new	vehid = GetPlayerVehicleID(playerid);
		SetVehicleNumberPlate( vehid, cmdtext);
		GameTextForPlayer(playerid,cmdtext,8000,1);
		return 1;
	}
I'm trying to get a plate number from the command and possibly assign a variable to it. It doesn't assign a license plate, but it prints "/setplate".


Respuesta: Getting strings from commands and printing variables - [DOG]irinel1996 - 12.11.2012

Give a try to this, I didn't test it:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/kick", true) == 0) {
        new tmp[128];
        tmp = strtok(cmdtext, idx);
       
        SetVehicleNumberPlate(GetPlayerVehicleID(playerid), tmp);
        GameTextForPlayer(playerid,tmp,8000,1);
        return 1;
    }
    return 0;
}
________________
PD: this is an old way, take a look to sscanf and zcmd.