CMD Help [DINI][sscanf]
#1

Hi, i've a problem with some sscanf CMD's, but I show you only a CMD.

Look:
Код:
dcmd_warn(playerid,params[])
{
  new idName[24];
  new aName[24];
  new idFile[300];
  new aFile[300];
  new string[256];
  new id;
  new warn[256];
  
  GetPlayerName(id,idName,sizeof(idName));
  GetPlayerName(playerid,aName,sizeof(aName));
  format(idFile,sizeof(idFile),PATH,idName);
  format(aFile,sizeof(aFile),PATH,aName);
  
  if(sscanf(params,"us",id,warn))
  {
   if(dini_Int(aFile,"Admin") >= 3)
   {
	SendClientMessage(playerid,0xFF0000AA,"Usa: /warn <id/nome> <motivo>  |  /swarn <id/nome>");
   }
   if(0 < dini_Int(aFile,"Admin") < 3)
   {
	SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin da Liv.3 in poi.");
   }
   if(dini_Int(aFile,"Admin") == 0)
   {
	SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin.");
   }
   return 1;
  }
  else
  {
   if(dini_Int(aFile,"Admin") >= 3)
   {
	if(id == INVALID_PLAYER_ID)
	{
	 SendClientMessage(playerid,0xFF0000AA,"ID non connesso!");
	}
	else if(!fexist(idFile))
	{
    format(string,sizeof(string),"L'admin %s ha mandato un avvertimento a %s [Motivo: %s ]",aName,idName,warn);
    SendClientMessageToAll(COLOR_YELLOW,string);
    PlayerPlaySound(id,1149,0,0,0);
    }
    else
    {
     dini_IntSet(idFile,"Warn",dini_Int(idFile,"Warn")+1);
     format(string,sizeof(string),"L'admin %s ha mandato un avvertimento a %s [Motivo: %s ] [%d/3]",aName,idName,warn,dini_Int(idFile,"Warn"));
     SendClientMessageToAll(COLOR_YELLOW,string);
     format(string,sizeof(string),"[WARN] %s ha mandato un avvertimento a %s [Motivo: %s ] [%d/3]",aName,idName,warn,dini_Int(idFile,"Warn"));
     print(string);
     PlayerPlaySound(id,1149,0,0,0);

     if(dini_Int(idFile,"Warn") == 3)
     {
      format(string,sizeof(string),"{FF0000}%s и stato cacciato dal Server.[Motivo: 3 avvertimenti per ''%s'' ]",idName,warn);
      SendClientMessageToAll(COLOR_WHITE,string);
	  format(string,sizeof(string),"[KICK] %s и stato cacciato.[Motivo: 3 avvertimenti per ''%s'' ]",idName,warn);
	  print(string);
      Kick(id);
     }
     return 1;
    }
    return 1;
   }
   if(0 < dini_Int(aFile,"Admin") < 3)
    {
	 SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin da Liv.3 in poi.");
    }
    if(dini_Int(aFile,"Admin") == 0)
    {
   	 SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin.");
    }
   }
   return 1;
}
This CMD is for warn players.
Problem: If i use this CMD with other players, warn goes to me. Example: I am ID 0, ok?
I want to warn ID 1.
I use: /warn 1 dfghbjnkmklnhjbg
I'm DanyelKing.


This is what that does: Admin DanyelKing has warned DanyelKing[reason: dfghbjnkmklnhjbg][1/3]

When I use /warn 0 abcdefg (my ID), it does the same thing.

Why?

Thanks for Help. Sorry for my Bad english, i'm Italian
Reply
#2

I won't make it for you but I can give you the idea of how to do it.

Use your admin system as you would like and if the player is an admin at the level you would like do the following;

Get the amount of warns of the selected player.
If the amount of warns equals to 0, use SendClientMessage(playerid, 0xFF0000AA, "1/3");
and set it to 1.
If the amount of warns equals to 1, use SendClientMessage(playerid, 0xFF0000AA, "2/3");
and set it to 2.
If the amount of warns equals to 2, use SendClientMessage(playerid, 0xFF0000AA, "3/3");
and set it to 3.
Reply
#3

It's a Good Idea, but it isn't the problem. The warn, with all ID i write in /warn <id> <text> , goes ever to the admin who give the warn, not to player. Anyway, thanks to advice
Reply
#4

Add pWarns.

So each time you warn him/her the warn will be added

Example

pWarns

add this when you warn him/her
pWarns[playerid]++;

And add for example under OnPlayerUpdate
Код:
if(pWarns[playerid] == 3)
{
	Ban(playerid);
	return 1;
}
Cut the code bit down

Код:
if(dini_Int(aFile,"Admin") >= 3)
   {
	SendClientMessage(playerid,0xFF0000AA,"Usa: /warn <id/nome> <motivo>  |  /swarn <id/nome>");
   }
   if(0 < dini_Int(aFile,"Admin") < 3)
   {
	SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin da Liv.3 in poi.");
   }
   if(dini_Int(aFile,"Admin") == 0)
   {
	SendClientMessage(playerid,0xFF0000AA,"Comando abilitato agli Admin.");
   }

Here is an example of entire command (not tested)
Код:
COMMAND:warn(playerid, params[])
{
    new pid, reason[105];
    if(PlayerInfo[playerid][pAdminlevel] >= 1) return SendClientMessage(playerid, 0xAAAAAAAA, "You are not admin or the required level.");
    if(sscanf(params, "us", pid, reason)) return SendClientMessage(playerid,  0xFFFFFFFF, "/warn [playerid/name] [reason]");
    if(IsPlayerConnected(pid) && pid != INVALID_PLAYER_ID && pid != playerid)
    {
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "%s has been warned by %s for: %s", paramname, adminname, reason);
        pWarns[pid]++;
        SendClientMessageToAll(AdminColor, string);
        Kick(pid);
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected Or Is Yourself.");
    return 1;
}
Reply
#5

Uhm it is dini_IntSet(idFile,"Warn",dini_Int(idFile,"Warn")+ 1) ...Anyway I'll try it
ID 0= DanyelKing
ID 1= abc

/warn 1 You'll kicked

Admin DanyelKing has warned DANYELKING [Reason: You'll kicked][%/3]

It should be:

Admin DanyelKing has warned abc [Reason: You'll kicked][%/3]

Then, Warn system work good, but not for correct player!
Reply
#6

Just take a look at my command. Also if you want to change the message exchange format

Код:
format(string, sizeof(string), "%s has been warned by %s for: %s", adminname, paramname, reason);
Reply
#7

Quote:
Originally Posted by Squirrel
Посмотреть сообщение
Just take a look at my command. Also if you want to change the message exchange format

Код:
format(string, sizeof(string), "%s has been warned by %s for: %s", adminname, paramname, reason);
Ok, I'll try it, but i think it's the same thing...
Reply
#8

I've Resolved, not for you, anyway thanks for Help replies Close please
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)