Can someone help me ?
#1

Can someone help mi with this commands ?
Код:
if(strcmp(cmd,"/tmute",true)==0)
	{
	    if(pInfo[playerid][pAdmin] >= 2)
	    {
			tmp = strtok(cmdtext,idx);
			if(!strlen(tmp))
			{
			    SendClientMessage(playerid,-1,"Използвай: /tmute [playerid] [reason] [time]");
			    return 1;
			}
			new player = ReturnUser(tmp);
			if(IsPlayerConnected(player))
			{
			    if(player != INVALID_PLAYER_ID)
			    {
			        	new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[256];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
				        if(!strlen(result))
				        {
				            SendClientMessage(playerid,-1,"Използвай: /tmute [playerid] [reason] [time]");
				    		return 1;
				        }
				        tmp = strtok(cmdtext,idx);
				        new time = strval(tmp);
				        if(!strval(tmp))
				        {
				            SendClientMessage(playerid,-1,"Използвай: /tmute [playerid] [reason] [time]");
				    		return 1;
				        }
				        if(pInfo[player][pMuted] == 0)
				        {
				            pInfo[player][pMuted] = 1;
				            pInfo[player][pMutedTime] = (gettime() + time*60);
				            format(string,sizeof(string),"%s беше заглушен от администратор %s за %d минути! [Причина: %s]",GetName(player),GetName(playerid),result,time);
				            SendClientMessageToAll(0xFF0000FF,string);
				        }
			    }
			}
		}
		else
		{
		    SendClientMessage(playerid, 0xFF0000FF, "Нямаш права за да ползваш командата!");
		    return 1;
		}
		return 1;
	}
the problem is for example: when i type /tmute 0 test 1
it returns "Използвай: /tmute [playerid] [reason] [time]"
Help me please
Reply
#2

use sscanf
PHP код:
if(sscanf(params"uis[128]"idtimereason)) 
and then mute the player with the id "id",for a "time" ammount and for a "reason"
Reply
#3

i used this
Код:
if(strcmp(cmd,"/tmute",true) == 0)
	{
	    if(pInfo[playerid][pAdmin] >= 2)
	    {
		    new id,time,reason[128];
		    if(sscanf(params,"uis[128]",id,time,reason)) return SendClientMessage(playerid,-1,"Използвай: /tmute [playerid] [time] [reason]");
		    if(IsPlayerConnected(id))
		    {
		        if(id != INVALID_PLAYER_ID)
		        {
		            if(pInfo[id][pMuted] != 1)
		            {
					pInfo[id][pMuted] = 1;
					pInfo[id][pMutedTime] = (gettime() + time*60);
					format(string,sizeof(string),"%s беше заглушен от администратор %s за %d минути[Причина: %s]",GetName(id),GetName(playerid),time,reason);
					SendClientMessageToAll(0xFF0000FF,string);
					return 1;
					}
					else
					{
					    SendClientMessage(playerid,-1,"Този играч вече е заглушен !");
	    				return 1;
					}
		        }
		    }
	    }
	    else
	    {
	        SendClientMessage(playerid, 0xFF0000FF, "Нямаш права за да ползваш командата!");
	        return 1;
	    }
	   	return 1;
	}
but that i have the same problem again
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)