pWarn in a string? Help?
#1

Код:
YCMD:warn(playerid, params[], help)
{
        #pragma unused help
        if(P_Data[playerid][pAdmin] < 3) return SCM(playerid, COLOR_RED, "You need to be admin level 3 to use this!");
        new
			pplayerid,string[128],reason[48];
        if(sscanf(params, "us[48]", pplayerid,reason)) return SCM(playerid, COLOR_RED, "Usage: /warn [Player ID/Player Name] [Reason]");
        if(pplayerid == IPI) return SCM(playerid, COLOR_RED, "Wrong playerid!");
		P_Data[pplayerid][pWarn] += 1;
		format(string,sizeof(string),"Admin %s warned you. Reason: %s",GetName(playerid),reason);
		SCM(pplayerid,-1,string);
		format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason,); //<--- Here!!!!
		SCM(playerid,-1,string);
		if(P_Data[pplayerid][pWarn] >=4) {
		Kick(pplayerid);}
		return 1;
}
Reply
#2

I don't know what you mean but, try this:
pawn Код:
format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason);
instead of this:
pawn Код:
format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason,);
EDIT:
Also you have a decimal place holder but no variable for it. This should fix it:
pawn Код:
format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason, P_Data[pplayerid][pWarn]);
Reply
#3

try looking after me and design your own
pawn Код:
CMD:warn(playerid,params[])
{
    if(PlayerInfo[playerid][Admin] >= 2)
    {
         new id, reason[69];
         if(sscanf(params,"us[69]",id,reason) ) return SendClientMessage(playerid,COLOR_RED,"USUAGE: /warn [id] [reason]");
         if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_BLUE,"Player is not connected.!");
         else
         {
                #if KICK_MAX_WARN == true
                new name[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
                           new string[256], strings[256];
                     GetPlayerName(id,playername,sizeof(playername));
                  GetPlayerName(playerid,name,sizeof(name));
                  format(string,sizeof(string),"You warned warn you %s for reason: %s",playername,reason[0]);
                  format(string,sizeof(strings),"%s warned you for reason: %s",name,reason[0]);
                     SendClientMessage(playerid,COLOR_YELLOW,string);
                     SendClientMessage(id,COLOR_BLUE,strings);
                     Warn[id]++;
                     
                     if(Warn[id] >= MAX_WARN_FOR_KICK)
                     {
                                   format(string,sizeof(string),"%s is now kicked ( to much warnings)",playername);
                           SendClientMessageToAll(COLOR_GREEN,string);
                           Kick(id);
                     }
                #endif
                #if BAN_MAX_WARN == true
                        new name[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
                           new string[256], strings[256];
                     GetPlayerName(id,playername,sizeof(playername));
                  GetPlayerName(playerid,name,sizeof(name));
                  format(string,sizeof(string),"You warned %s {reason: %s}",playername,reason[0]);
                  format(string,sizeof(strings),"%s warned you {reason: %s}",name,reason[0]);
                     SendClientMessage(playerid,COLOR_YELLOW,string);
                     SendClientMessage(id,COLOR_BLUE,strings);
                     Warn[id]++;

                     if(Warn[id] >= MAX_WARN_FOR_BAN)
                     {
                              format(string,sizeof(string),"%s is now banned ( to much warnings)",playername);
                           SendClientMessageToAll(COLOR_GREEN,string);
                           Ban(id);
                     }
                   
                #endif
         }
    }
    else SendClientMessage(playerid,COLOR_RED,"You need to be an Admin!");
   return 1;
}
Reply
#4

Im trying to add players current warnings "pWarn" into the string (%d/4) you see?
Код:
		format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason,pWarn); //<--- Here!!!!
// It's working with pWarn but then is it allways saying 8/4
Reply
#5

Quote:
Originally Posted by mrsamp
Посмотреть сообщение
Im trying to add players current warnings "pWarn" into the string (%d/4) you see?
Код:
		format(string,sizeof(string),"%s has been warned: %s (%d/4)",GetName(pplayerid),reason,pWarn); //<--- Here!!!!
// It's working with pWarn but then is it allways saying 8/4
Read my post, just edited it ^^^.
Reply
#6

WOW No errors Hope it's working now then

It's working Thдnks!
Reply
#7

No problem mate.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)