Getting strings from commands and printing variables
#1

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)