Issue with params
#1

I'm having and Issue Transitioning these 3 commands From cmdtext to dcmd. cmd's works fine but example when I type example /write 3(id) hello (text) , it doesn't show part of the message or is a different color. whats my problem here? I figure its strmid what do you think the problem is?

CODE:

Код:
dcmd_pm(playerid,params[]){
		new dir[256],tmp[256], Index;
     	dir = strtok(params, Index);
		strmid(tmp, params, 0, strlen(params));
		if(!strlen(dir) || strlen(dir) > 5) {
			SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (your id) (message)");
			return 1;
		}
		dir = strtok(params, Index);
		new id = strval(tmp);
        gMessage = strrest(params,Index);

		if(!strlen(gMessage)) {
			SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (your id) (message)");
			return 1;
		}

		if(!IsPlayerConnected(id)) {
			SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/pm : Bad player ID");
			return 1;
		}

		if(playerid != id) {
			GetPlayerName(id,iName,sizeof(iName));
			GetPlayerName(playerid,pName1,sizeof(pName1));
			format(Message,sizeof(Message),">> %s(%d): %s",iName,id,gMessage);
			SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
			format(Message,sizeof(Message),"** %s(%d): %s",pName1,playerid,gMessage);
			SendClientMessage(id,PM_INCOMING_COLOR,Message);
			PlayerPlaySound(id,1085,0.0,0.0,0.0);

			printf("PM: %s",Message);

		}
		else {
			SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"You cannot PM yourself");
		}
		return 1;
	}

dcmd_spam(playerid,params[]) {
		if(PlayerInfo[playerid][Level] >= 3) {
			new dir[256],tmp[256], Index,string[128];
			dir = strtok(params, Index);
	    	strmid(tmp, params, 0, strlen(params));
			if(!strlen(dir)) {
				SendClientMessage(playerid, 0xFFFF00FF, "USAGE: /spam [Colour] [Text]");
				SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=Black 1= 2=0xFFFF00FF 3=0xFFFF00FF 4=0xFFFF00FF 5=0xFFFF00FF 6=0xFFFF00FF 7=purple 8=brown 9=pink");
				return 1;
			}
			dir = strtok(params, Index);
			new Colour = strval(tmp);
			if(Colour > 9 ) return SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=0xFFFF00FF 1=0xFFFF00FF 2=0xFFFF00FF 3=0xFFFF00FF 4=0xFFFF00FF 5=0xFFFF00FF 6=0xFFFF00FF 7=purple 8=brown 9=pink");

			format(string, sizeof(string), "%s", tmp);

	        if(Colour == 0) 	 for(new i; i < 50; i++) SendClientMessageToAll(0x40404050,string);
	        else if(Colour == 1) for(new i; i < 50; i++) SendClientMessageToAll(0xFFFFFF50,string);
	        else if(Colour == 2) for(new i; i < 50; i++) SendClientMessageToAll(0xFF000050,string);
	        else if(Colour == 3) for(new i; i < 50; i++) SendClientMessageToAll(0xFF800050,string);
	        else if(Colour == 4) for(new i; i < 50; i++) SendClientMessageToAll(0xFFFF0050,string);
	        else if(Colour == 5) for(new i; i < 50; i++) SendClientMessageToAll(0x00FF0050,string);
	        else if(Colour == 6) for(new i; i < 50; i++) SendClientMessageToAll(0x0040FF50,string);
	        else if(Colour == 7) for(new i; i < 50; i++) SendClientMessageToAll(0xFF00FF50,string);
	        else if(Colour == 8) for(new i; i < 50; i++) SendClientMessageToAll(0x994D0050,string);
	        else if(Colour == 9) for(new i; i < 50; i++) SendClientMessageToAll(0xFF80FF50,string);
			return 1;
		} else return SendClientMessage(playerid,0xFFFF00FF,"ERROR: You need to be level 3 to use this command");
	}
	
dcmd_write(playerid,params[]) {
	if(PlayerInfo[playerid][Level] >= 1) {
	new dir[256],tmp[256], Index,string[128];
		dir = strtok(params, Index);
	    strmid(tmp, params, 0, strlen(params));
		if(!strlen(dir)) {
			SendClientMessage(playerid, 0xFFFF00FF, "USAGE: /write [Colour] [Text]");

			return SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=Black 1=White 2=Red 3=Orange 4=Yellow 5=Green 6=Blue 7=Purple 8=Brown 9=Pink");
	 	}
	 	dir = strtok(params, Index);
		new Colour;
		Colour = strval(tmp);
		if(Colour > 9 )	{
			SendClientMessage(playerid, 0xFFFF00FF, "USAGE: /write [Colour] [Text]");

			return SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=Black 1=White 2=Red 3=Orange 4=Yellow 5=Green 6=Blue 7=Purple 8=Brown 9=Pink");
		}
		dir = strtok(params, Index);

        CMDMessageToAdmins(playerid,"WRITE");



        if(Colour == 0) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0x40404050,string); return 1;	}
        else if(Colour == 1) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFFFFFF50,string); return 1;	}
        else if(Colour == 2) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFF000050,string); return 1;	}
        else if(Colour == 3) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFF800050,string); return 1;	}
        else if(Colour == 4) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFFFF0050,string); return 1;	}
        else if(Colour == 5) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0x00FF0050,string); return 1;	}
        else if(Colour == 6) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0x0040FF50,string); return 1;	}
        else if(Colour == 7) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFF00FF50,string); return 1;	}
        else if(Colour == 8) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0x994D0050,string); return 1;	}
        else if(Colour == 9) {	format(string,sizeof(string),"%s",tmp);	SendClientMessageToAll(0xFF80FF50,string); return 1;	}
        return 1;
	} else return SendClientMessage(playerid,0xFFFF00FF,"ERROR: You need to be level 1 to use this command");
	}
Reply
#2

use sscanf for params
Reply
#3

Try this out. This is just the first two.

pawn Код:
dcmd_pm(playerid,params[])
{
    new id,msg[128];
    if(sscanf(params,"ds",id,msg))
    {
        SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /pm (id) (message)");
        return 1;
    }
    if(!IsPlayerConnected(id))
    {
        SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: Given player ID not connected.");
        return 1;
    }
    if(playerid == id)
    {
        SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: You cannot PM yourself.");
        return 1;
    }

    new name[24],name2[24],final[128];
    GetPlayerName(id,name,sizeof(name));
    GetPlayerName(playerid,name2,sizeof(name2));
    format(Message,sizeof(Message),">> %s(%d): %s",name,id,msg);
    SendClientMessage(playerid,PM_OUTGOING_COLOR,Message);
    format(Message,sizeof(Message),"** %s(%d): %s",name2,playerid,msg);
    SendClientMessage(id,PM_INCOMING_COLOR,Message);
    PlayerPlaySound(id,1085,0.0,0.0,0.0);

    printf("PM: %s",Message);
    return 1;
}

dcmd_spam(playerid,params[])
{
    if(PlayerInfo[playerid][Level] >= 3)
    {
        new color,text[128];
        if(sscanf(params,"ds",color,text))
        {
            SendClientMessage(playerid, 0xFFFF00FF, "Usage: /spam (color) (text)");
            SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=Black 1= 2=0xFFFF00FF 3=0xFFFF00FF 4=0xFFFF00FF 5=0xFFFF00FF 6=0xFFFF00FF 7=Purple 8=Brown 9=Pink");
            return 1;
        }
        if(color < 0 || color > 9)
        {
            SendClientMessage(playerid, 0xFFFF00FF, "Usage: /spam (color) (text)");
            SendClientMessage(playerid, 0xFFFF00FF, "Colours: 0=Black 1= 2=0xFFFF00FF 3=0xFFFF00FF 4=0xFFFF00FF 5=0xFFFF00FF 6=0xFFFF00FF 7=Purple 8=Brown 9=Pink");
            return 1;
        }

        switch(color)
        {
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0x40404050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFFFFFF50,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFF000050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFF800050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFFFF0050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0x00FF0050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0x0040FF50,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFF00FF50,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0x994D0050,string);
            case 0:for(new i; i < 50; i++) SendClientMessageToAll(0xFF80FF50,string);
        }
        return 1;
    }
    else
    {
        SendClientMessage(playerid,0xFFFF00FF,"ERROR: You need to be level 3 to use this command");
        return 1;
    }
}
You'll need sscanf.
Reply
#4

i tried sscanf doesn't work. nothing shows up just clear
Reply
#5

anything else u can suggest?
Reply
#6

anything?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)