SA-MP Forums Archive
Help with a ban command y_ini saving ''reason'' - 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: Help with a ban command y_ini saving ''reason'' (/showthread.php?tid=370348)



Help with a ban command y_ini saving ''reason'' - caki - 19.08.2012

Okay so i tried everything to get this work properly but it's driving me nuts. I want that ''reason'' is saved in //
pawn Код:
PlayerInfo[playerid][pBanReason] = reason;
but i can't manage to get it work i keep getting 006 error and when i use
pawn Код:
format(PlayerInfo[playerid][pBanReason], 128, "%s", reason);
i got saved under reason number 84 .Any help would be appriciated.Thanks

pawn Код:
YCMD:ban(playerid, params[], help)
{

                new id, reason[128], str[128], str1[128], str2[128],str3[128] mins, sec, year, month, day;
                if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin]<=1338)
                if (sscanf(params, "ds[128]", id, reason)) SendClientMessage(playerid, COLOR_INFO, "Usage: \"/ban [playerid] [reason]\"");
                else if (!IsPlayerConnected(id)) SendClientMessage(playerid, COLOR_RED, "Invalid id");
                else
          //      if (!IsPlayerConnected(id)) SendClientMessage(playerid, COLOR_YELLOW, "Invalid id");
                {
                     
                        gettime(hour, mins, sec);
                        getdate(year, month, day);
                        //PlayerInfo[playerid][pBanReason] = reason;
                        format(str, 128, "Time: %i:%i Date: %i/%i/%i", hour, mins, day, month, year);
                        SendClientMessage(id, COLOR_RED, str);
                        format(str1, 128, "Admin: %s Banned: %s Reason: %s", GetName(playerid),GetName(playerid), reason);
                        SendClientMessageToAll(COLOR_RED,str1);
                        format(str2, 128, "You have been Banned from the server by Admin: %s Reason: %s",GetName(playerid), reason);
                        SendClientMessage(id, COLOR_RED, str2);
                       format(str3, 128, "~r~~h~Banned ~n~~r~");
                GameTextForPlayer(id, str3, 6000, 3);
           
                        PlayerInfo[playerid][pBanned]= 1;
                     //   format(PlayerInfo[playerid][pBanReason], 128, "%s", reason);
                    //    PlayerInfo[playerid][pBanReason] = reason;
                        Kick(id);
                }
                else
                {
                SendClientMessage(playerid, COLOR_YELLOW, "You are not authorized to use that command!");
                }
                return 1;

}



Re: Help with a ban command y_ini saving ''reason'' - Kitten - 19.08.2012

shouldn't it be

pawn Код:
new string[128];
format(string, sizeof(string), "%s", reason);



Re: Help with a ban command y_ini saving ''reason'' - MadeMan - 19.08.2012

Show how you create pBanReason in the enum.


AW: Help with a ban command y_ini saving ''reason'' - Mellnik - 19.08.2012

you have to add [128] by pBanReason in the enum


Re: Help with a ban command y_ini saving ''reason'' - Shadow_ - 19.08.2012

Quote:
Originally Posted by Kitten
Посмотреть сообщение
shouldn't it be

pawn Код:
new string[128];
format(string, sizeof(string), "%s", reason);
He has done that :/

" // format(PlayerInfo[playerid][pBanReason], 128, "%s", reason);
// PlayerInfo[playerid][pBanReason] = reason;"

PlayerInfo[playerid][pBanReason] = String
128 = sizeof
%s = string identifer
reason = string.


Re: Help with a ban command y_ini saving ''reason'' - necrobg3 - 19.08.2012

Why you use Ycmd? There are better ways to script.


Re: Help with a ban command y_ini saving ''reason'' - caki - 19.08.2012

Quote:
Originally Posted by Kitten
Посмотреть сообщение
shouldn't it be

pawn Код:
new string[128];
format(string, sizeof(string), "%s", reason);
That wont work since it will save 0

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Show how you create pBanReason in the enum.
pBanReason[128],

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
you have to add [128] by pBanReason in the enum
pBanReason[128],

pawn Код:
if (sscanf(params, "ds[128]", id, reason)) SendClientMessage(playerid, COLOR_INFO, "Usage: \"/ban [playerid] [reason]\"");
format(PlayerInfo[playerid][pBanReason], 128, "%s", reason);
PlayerInfo[playerid][pBanReason] = reason;
Output of this in save file is 84 no matter what i put under /ban id reason


AW: Help with a ban command y_ini saving ''reason'' - Mellnik - 19.08.2012

Also using "r" instead of "d" in sscanf would be usefull

if(sscanf(params, "rs[128]", player, reason))
{...}


Re: Help with a ban command y_ini saving ''reason'' - SuperViper - 19.08.2012

pawn Код:
PlayerInfo[playerid][pBanReason] = reason;
should be

pawn Код:
format(PlayerInfo[playerid][pBanReason], 50, reason);



Re: Help with a ban command y_ini saving ''reason'' - caki - 20.08.2012

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
PlayerInfo[playerid][pBanReason] = reason;
should be

pawn Код:
format(PlayerInfo[playerid][pBanReason], 50, reason);
It is same what i use this above or format ban reason is always 84. All this didn't helped problem is same anyone have idea