Can someone help me ? - 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: Can someone help me ? (
/showthread.php?tid=651379)
Can someone help me ? -
scripter112 - 19.03.2018
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
Re: Can someone help me ? -
PepsiCola23 - 19.03.2018
use sscanf
PHP код:
if(sscanf(params, "uis[128]", id, time, reason))
and then mute the player with the id "id",for a "time" ammount and for a "reason"
Re: Can someone help me ? -
scripter112 - 19.03.2018
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