SA-MP Forums Archive
[HELP]My Commands Doesn't work again - 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]My Commands Doesn't work again (/showthread.php?tid=484703)



[HELP]My Commands Doesn't work again - donhu789 - 01.01.2014

pawn Код:
CMD:ban(playerid, params[])
{
    if(!PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, red, "ERROR: You must be logged in to use this commands");
    if(PlayerInfo[playerid][Level] < 7) return SendClientMessage(playerid, red, "ERROR: You are not a high enough level to use this command");
    new targetid, reason[40];
    if(sscanf(params, "is[40]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Player is not connected.");
    if(targetid == playerid) return SendClientMessage(playerid, red, "You cannot ban yourself.");
    if(PlayerInfo[targetid][Level] == ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "The Player You Are Trying To Ban Is The Highest Admin !");
    new PlayerName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME], string[150];
    GetPlayerName(playerid, AdminName, sizeof(AdminName));
    GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
    new year, month, day, hour, minute, second;
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(string, sizeof(string), "{FF0000}YG INFO - %s (ID: %d) has been banned by Administrator %s (ID: %d) [Reason: %s]", PlayerName, targetid, AdminName, playerid, reason);
    SendClientMessageToAll(red, string);
    CMDMessageToAdmins(playerid, "Ban");
    SaveToFile("BanLog", string);
    aresetpall(targetid);
    print(string);
    if(udb_Exists(PlayerName2(targetid)) && PlayerInfo[targetid][LoggedIn] == 1) dUserSetINT(PlayerName2(targetid)).("banned",1);
    SendClientMessage(targetid, red, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    SendClientMessage(targetid, red, "YOU HAVE BEEN BANNED - READ THE FOLLOWING DETAILS:");
    format(string, sizeof(string), "Your Name: %s", PlayerName);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Admin Name: %s", AdminName);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Date And Time: %d/%d/%d %d:%d", day, month, year, hour, minute);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Reason: %s", reason);
    SendClientMessage(targetid, green, string);
    SendClientMessage(targetid, green, "(If You Wish To Make an Appeal goto YG-Gamers.tk and post in the Unban Appeals Category.)");
    SendClientMessage(targetid, red, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    return SetTimerEx("BanTimer", 200, false, "is", playerid, reason);
}

forward BanTimer(playerid, reason[]);
public BanTimer(playerid, reason[]) return BanEx(playerid, reason);

CMD:rban(playerid, params[])
{
    if(!PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, red, "ERROR: You must be logged in to use this commands");
    if(PlayerInfo[playerid][Level] < 7) return SendClientMessage(playerid, red, "ERROR: You are not a high enough level to use this command");
    new targetid, reason[40];
    if(sscanf(params, "is[40]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /rban [playerid] [reason]");
    if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Player is not connected.");
    if(targetid == playerid) return SendClientMessage(playerid, red, "You cannot ban yourself.");
    if(PlayerInfo[targetid][Level] == ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid, red, "The Player You Are Trying To Ban Is The Highest Admin !");
    new PlayerName[MAX_PLAYER_NAME], AdminName[MAX_PLAYER_NAME], string[150];
    GetPlayerName(playerid, AdminName, sizeof(AdminName));
    GetPlayerName(targetid, PlayerName, sizeof(PlayerName));
    new year, month, day, hour, minute, second;
    getdate(year, month, day);
    gettime(hour, minute, second);
    format(string, sizeof(string), "{FF0000}YG INFO - %s (ID: %d) has been Range banned by Administrator %s (ID: %d) [Reason: %s]", PlayerName, targetid, AdminName, playerid, reason);
    SendClientMessageToAll(red, string);
    CMDMessageToAdmins(playerid, "rBan");
    SaveToFile("BanLog", string);
    aresetpall(targetid);
    print(string);
    if(udb_Exists(PlayerName2(targetid)) && PlayerInfo[targetid][LoggedIn] == 1) dUserSetINT(PlayerName2(targetid)).("banned",1);
    SendClientMessage(targetid, red, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    SendClientMessage(targetid, red, "YOU HAVE BEEN RANGE BANNED - READ THE FOLLOWING DETAILS:");
    format(string, sizeof(string), "Your Name: %s", PlayerName);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Admin Name: %s", AdminName);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Date And Time: %d/%d/%d %d:%d", day, month, year, hour, minute);
    SendClientMessage(targetid, green, string);
    format(string, sizeof(string), "Reason: %s", reason);
    SendClientMessage(targetid, green, string);
    SendClientMessage(targetid, green, "(If You Wish To Make an Appeal goto YG-Gamers.tk and post in the Unban Appeals Category.)");
    SendClientMessage(targetid, red, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    return SetTimerEx("rBanTimer", 200, false, "is", playerid, reason);
}

forward rBanTimer(playerid, reason[]);
public rBanTimer(playerid, reason[]) return BanEx(playerid, reason);

guys help me commands ain't working !

i preass /rban 1 test is respond /rban [id] [reason]


i preass /ban 2 test is respond /ban [id] [reason]


what the hell going on ?


Re: [HELP]My Commands Doesn't work again - newbie scripter - 01.01.2014

problem with ur sscanf code i think...


Re: [HELP]My Commands Doesn't work again - RowdyrideR - 01.01.2014

Try

Код:
if(sscanf(params, "ds[40]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
Not sure.


Re: [HELP]My Commands Doesn't work again - AA9 - 01.01.2014

pawn Код:
Specifier(s)    Name    Example values
b   Binary  01001, 0b1100
c   Character   a, o, *
f   Float   0.7, -99.5
g   IEEE Float  0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
h, x    Hex 1A, 0x23
i, d    Integer 1, 42, -10
l   Logical true, false
n   Number  42, 0b010, 0xAC, 045
o   Octal   045 12
q   Bot name/id ShopBot, 27
r   Player name/id  ******, 42
u   User name/id (bots and players) ******, 0
pawn Код:
if(sscanf(params, "us[40]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");



Re: [HELP]My Commands Doesn't work again - dominik523 - 01.01.2014

Quote:
Originally Posted by RowdyrideR
Посмотреть сообщение
Try

Код:
if(sscanf(params, "ds[40]", targetid, reason)) return SendClientMessage(playerid, red, "USAGE: /ban [playerid] [reason]");
Not sure.
d and i specifiers are the same, and they work for only integers. You need to use "us[40]" because u is for player IDs


Re: [HELP]My Commands Doesn't work again - Konstantinos - 01.01.2014

Quote:
Originally Posted by dominik523
Посмотреть сообщение
d and i specifiers are the same, and they work for only integers. You need to use "us[40]" because u is for player IDs
Player IDs are integers so i, d, u, r will work for the player's ID. The difference between r, u and the rest is that the player's name can be used too. u specifier will work for both players and NPCs but r only for players.

@donhu789: Update sscanf plugin and include to its latest version and re-compile. Try again.


Re: [HELP]My Commands Doesn't work again - dominik523 - 01.01.2014

Thanks Konstantinos for pointing it out for me. I haven't thought of that until now.


Re: [HELP]My Commands Doesn't work again - newbie scripter - 01.01.2014

just a question, is "S" a specifier in sscanf?


Re: [HELP]My Commands Doesn't work again - Konstantinos - 01.01.2014

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
just a question, is "S" a specifier in sscanf?
Yes, it's optional string.

Quote:
Originally Posted by ******
Посмотреть сообщение
For quick reference, here is a list of ALL the specifiers and their use:

Specifier Format Use
A A<type>(default)[length] Optional array of given type
B B(binary) Optional binary number
C C(character) Optional character
D D(integer) Optional integer
E E<specification>(default) Optional enumeration of given layout
F F(float) Optional floating point number
G G(float/INFINITY/-INFINITY/NAN/NAN_E) Optional float with IEEE definitions
H H(hex value) Optional hex number
I I(integer) Optional integer
K K<callback>(any format number) Optional custom operator
L L(true/false) Optional logical truthity
N N(any format number) Optional number
O O(octal value) Optional octal value
P P<delimiters> Multiple delimiters change
Q Q(any format number) Optional bot (bot)
R R(any format number) Optional player (player)
S S(string)[length] Optional string
U U(any format number) Optional user (bot/player)
Z Z(string)[length] Invalid optional string
a a<type>[length] Array of given type
b b Binary number
c c Character
d d Integer
e e<specification> Enumeration of given layout
f f Floating point number
g g Float with IEEE definitions
h h Hex number
i i Integer
k k<callback> Custom operator
l l Logical truthity
n n Number
o o Octal value
p p<delimiter> Delimiter change
q q Bot (bot)
s s[length] String
r r Player (player)
u u User (bot/player)
z z(string)[length] Deprecated optional string
{ { Open quiet section
} } Close quiet section
' 'string' Search string
% % Deprecated optional specifier prefix
? ? Local options specifier



Re: [HELP]My Commands Doesn't work again - newbie scripter - 01.01.2014

whats the use of "Optional String"?