/ban ID Reason. Reason wont show.
#1

Hello I would like need help with my /ban ID Reason that doesnt shows reason.
http://pastebin.com/XGpxQ8VR
Well. Thanks.
Reply
#2

try
Код:
CMD:ban(playerid, params[])
{
     if(IsPlayerAdmin(playerid))
     {
     new targetidname[MAX_PLAYER_NAME], targetid, reason, string[148];
     if(sscanf(params, "us[36]", targetid, reason)) return SendClientMessage(playerid,COLOR_RED,"Use: /ban ID           Reason");
     if(!IsPlayerConnected(playerid)) printf("That player is not Connected!", playerid);
     else
     GetPlayerName(targetid, targetidname, sizeof(targetidname));
     format(string,sizeof(string),"[AdmWarn] %s Has been Admin Banned. Reason: %s.", targetidname, reason);
     SendClientMessageToAll(COLOR_RED, string);
     SendClientMessage(targetid, -1, "You has been Banned by an Administrator");
     Ban(targetid);
     }
     else
     SendClientMessage(playerid, COLOR_RED, "You are not Logged in as Admin.");
     return 1;
}
Reply
#3

Quote:
Originally Posted by Fich
Посмотреть сообщение
try
Код:
CMD:ban(playerid, params[])
{
     if(IsPlayerAdmin(playerid))
     {
     new targetidname[MAX_PLAYER_NAME], targetid, reason, string[148];
     if(sscanf(params, "us[36]", targetid, reason)) return SendClientMessage(playerid,COLOR_RED,"Use: /ban ID           Reason");
     if(!IsPlayerConnected(playerid)) printf("That player is not Connected!", playerid);
     else
     GetPlayerName(targetid, targetidname, sizeof(targetidname));
     format(string,sizeof(string),"[AdmWarn] %s Has been Admin Banned. Reason: %s.", targetidname, reason);
     SendClientMessageToAll(COLOR_RED, string);
     SendClientMessage(targetid, -1, "You has been Banned by an Administrator");
     Ban(targetid);
     }
     else
     SendClientMessage(playerid, COLOR_RED, "You are not Logged in as Admin.");
     return 1;
}
That made the command not work.
Reply
#4

maybe change new reason[128];
Reply
#5

That printf you use don't really make a sense. Also, the sendclientmessage to the tagetid is useless as he will never see, try to add a timer for some milisecond till he will be banned, then you can send him the message.

Well, remove that print, and use instead of it a return SendClienMessage, then you can also remove the else.
Reply
#6

Quote:
Originally Posted by Fich
Посмотреть сообщение
try
Код:
CMD:ban(playerid, params[])
{
     if(IsPlayerAdmin(playerid))
     {
     new targetidname[MAX_PLAYER_NAME], targetid, reason, string[148];
     if(sscanf(params, "us[36]", targetid, reason)) return SendClientMessage(playerid,COLOR_RED,"Use: /ban ID           Reason");
     if(!IsPlayerConnected(playerid)) printf("That player is not Connected!", playerid);
     else
     GetPlayerName(targetid, targetidname, sizeof(targetidname));
     format(string,sizeof(string),"[AdmWarn] %s Has been Admin Banned. Reason: %s.", targetidname, reason);
     SendClientMessageToAll(COLOR_RED, string);
     SendClientMessage(targetid, -1, "You has been Banned by an Administrator");
     Ban(targetid);
     }
     else
     SendClientMessage(playerid, COLOR_RED, "You are not Logged in as Admin.");
     return 1;
}
Quote:
Originally Posted by Flori
Посмотреть сообщение
That printf you use don't really make a sense. Also, the sendclientmessage to the tagetid is useless as he will never see, try to add a timer for some milisecond till he will be banned, then you can send him the message.

Well, remove that print, and use instead of it a return SendClienMessage, then you can also remove the else.
Well this doesnt work.
Код:
    if(!IsPlayerConnected(playerid)) SendClientMessage(playerid, "That player is not connected!");
Reply
#7

Use This.

PHP код:
#include <a_samp>
#include <sscanf>
#include < zcmd >
#define COLOR_RED 0xBB0004FF
CMD:ban(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
    new 
TargetName[MAX_PLAYER_NAME], TargetIDReason[128], string[148];
    
GetPlayerName(TargetID,TargetName,24);
    
    if(
sscanf(params"us"TargetIDReason))
    {
    
SendClientMessage(playerid,COLOR_RED,"Use: /ban ID Reason");
    return 
1;
    }
    if(!
IsPlayerConnected(playerid))
    {
    
SendClientMessage(playeridCOLOR_RED,"That Player Is Not Connected!");
    return 
1;
    }
    
    
format(string,sizeof(string),"[BAN] %s Has been Admin Banned. Reason: %s."TargetNameReason);
    
SendClientMessageToAll(COLOR_REDstring);
    
SendClientMessage(TargetID, -1"You Have Been Banned by An Administrator");
    
SetTimerEx("BanEx"1000false"i"TargetID);
    }else{
    
SendClientMessage(playeridCOLOR_RED"You Are Not Logged In As Admin.");
    }
    return 
1;
}
forward BanEx(playerid);
public  
BanEx(playerid)
{
    
Ban(playerid);
    return 
1;

Reply
#8

Oh ffs.
pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Are Not Logged In As Admin.");
    new targetid, reason[60];
    if(sscanf(params, "us[60]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Use: /ban ID Reason");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That Player Is Not Connected!");
    new string[128], TargetName[MAX_PLAYER_NAME];
    GetPlayerName(targetid, TargetName, sizeof(TargetName));
    format(string, sizeof(string), "[BAN] %s Has been Admin Banned. Reason: %s.", TargetName, reason);
    SendClientMessageToAll(COLOR_RED, string);
    SendClientMessage(targetid, -1, "You Have Been Banned by An Administrator");
    SetTimerEx("BanPlayer", 200, false, "i", targetid);
    return 1;
}

forward BanPlayer(playerid);
public BanPlayer(playerid) return Ban(playerid);

First issue:
pawn Код:
new targetidname[MAX_PLAYER_NAME], targetid, reason, string[148];
You defined 'reason' as an integer/number, not a string.

Second issue:
pawn Код:
if(sscanf(params, "u", targetid, reason))
You forgot to include the 's' specifier for a string, which would have been your 'reason'.

Third issue:
pawn Код:
if(!IsPlayerConnected(playerid))
'playerid' is the id of the player who typed the command. So by using IsPlayerConnected(playerid) instead of IsPlayerConnected(targetid), you are checking whether you are online, rather than the player you're targetting is online.

Fourth issue:
pawn Код:
printf("That player is not Connected!", playerid);
You used printf instead of SendClientMessage....

Fifth Issue:
pawn Код:
"You has been Banned by an Administrator"
Dat spelling, and the player would not see it because you ban them immediately. Hence the addition of the timer thanks to the security upgrades introduced 0.3e (or was it 0.3x?).

----

Basically, mistakes are easy to fix and learn from.
Reply
#9

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Oh ffs.
pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You Are Not Logged In As Admin.");
    new targetid, reason[60];
    if(sscanf(params, "us[60]", targetid, reason)) return SendClientMessage(playerid, COLOR_RED, "Use: /ban ID Reason");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That Player Is Not Connected!");
    new string[128], TargetName[MAX_PLAYER_NAME];
    GetPlayerName(targetid, TargetName, sizeof(TargetName));
    format(string, sizeof(string), "[BAN] %s Has been Admin Banned. Reason: %s.", TargetName, reason);
    SendClientMessageToAll(COLOR_RED, string);
    SendClientMessage(targetid, -1, "You Have Been Banned by An Administrator");
    SetTimerEx("BanEx", 200, false, "i", targetid);
    return 1;
}

forward BanEx(playerid);
public BanEx(playerid) return Ban(playerid);

First issue:
pawn Код:
new targetidname[MAX_PLAYER_NAME], targetid, reason, string[148];
You defined 'reason' as an integer/number, not a string.

Second issue:
pawn Код:
if(sscanf(params, "u", targetid, reason))
You forgot to include the 's' specifier for a string, which would have been your 'reason'.

Third issue:
pawn Код:
if(!IsPlayerConnected(playerid))
'playerid' is the id of the player who typed the command. So by using IsPlayerConnected(playerid) instead of IsPlayerConnected(targetid), you are checking whether you are online, rather than the player you're targetting is online.

Fourth issue:
pawn Код:
printf("That player is not Connected!", playerid);
You used printf instead of SendClientMessage....

Fifth Issue:
pawn Код:
"You has been Banned by an Administrator"
Dat spelling, and the player would not see it because you ban them immediately. Hence the addition of the timer thanks to the security upgrades introduced 0.3e (or was it 0.3x?).

----

Basically, mistakes are easy to fix and learn from.
Dayum, Well im still learning Pawno haha.
Reply
#10

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)