SA-MP Forums Archive
What is this ?! - 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: What is this ?! (/showthread.php?tid=553121)



What is this ?! - nezo2001 - 28.12.2014

[IMG][/IMG]
See the chat above.....
where is the rest of the name ??
Here is the code
PHP код:
CMD:ban(playeridparams[])
{
    new 
targetid;
    if(
PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playeridCOLOR_RED"You can't use this command");
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"This player is not connected");
    if(
sscanf(params,"u"targetid)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /ban [id]");
    {
    new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    new 
admin[MAX_PLAYER_NAME], string1[24+MAX_PLAYER_NAME];
    
GetPlayerName(playeridadminsizeof(admin));
    
GetPlayerName(targetidnamesizeof(name));
    
format(stringsizeof(string), "%s has been banned by an admin %s"nameadmin);
    
SendClientMessageToAll(COLOR_REDstring);
    
PlayerInfo[targetid][pBan] = 1;
    
SetTimerEx("KickDelay"2000false"i"playerid);
    }
    return 
true;




Re: What is this ?! - Ryz - 28.12.2014

post image


Re: What is this ?! - JeaSon - 28.12.2014

change string size

pawn Код:
CMD:ban(playerid, params[])
{
    new targetid;
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [id]");
    {
    new name[MAX_PLAYER_NAME], string[32];
    new admin[MAX_PLAYER_NAME];
    GetPlayerName(playerid, admin, sizeof(admin));
    GetPlayerName(targetid, name, sizeof(name));
    format(string, sizeof(string), "%s has been banned by an admin %s", name, admin);
    SendClientMessageToAll(COLOR_RED, string);
    PlayerInfo[targetid][pBan] = 1;
    SetTimerEx("KickDelay", 2000, false, "i", playerid);
    }
    return true;
}



Re: What is this ?! - nezo2001 - 28.12.2014

All the name disapeared
Please Help !!


Re: What is this ?! - Facerafter - 28.12.2014

Nvm, didn't read the OP good enough.


Respuesta: What is this ?! - aoEXE - 28.12.2014

you assigned few cells to the variable!

pawn Код:
CMD:ban(playerid, params[])
{
    new targetid;
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [id]");
    {
    new name[MAX_PLAYER_NAME], string[78];
    new admin[MAX_PLAYER_NAME];
    GetPlayerName(playerid, admin, sizeof(admin));
    GetPlayerName(targetid, name, sizeof(name));
    format(string, sizeof(string), "%s has been banned by an admin %s", name, admin);
    SendClientMessageToAll(COLOR_RED, string);
    PlayerInfo[targetid][pBan] = 1;
    SetTimerEx("KickDelay", 2000, false, "i", playerid);
    }
    return true;
}
Quote:
Originally Posted by Facerafter
Посмотреть сообщение
Can you show us OnPlayerConnect?
really? -_-


Re: What is this ?! - UltraScripter - 28.12.2014

Why you add another name string??
pawn Код:
new name[MAX_PLAYER_NAME], string[24];
new admin[MAX_PLAYER_NAME], string1[24];



Re: What is this ?! - Ahmad45123 - 28.12.2014

Try making the string array size bigger.

Here:
pawn Код:
CMD:ban(playerid, params[])
{
    new targetid;
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ban [id]");
    {
    new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME + MAX_PLAYER_NAME ];
    new admin[MAX_PLAYER_NAME], string1[24+MAX_PLAYER_NAME];
    GetPlayerName(playerid, admin, sizeof(admin));
    GetPlayerName(targetid, name, sizeof(name));
    format(string, sizeof(string), "%s has been banned by an admin %s", name, admin);
    SendClientMessageToAll(COLOR_RED, string);
    PlayerInfo[targetid][pBan] = 1;
    SetTimerEx("KickDelay", 2000, false, "i", playerid);
    }
    return true;
}



Re: What is this ?! - Sawalha - 28.12.2014

string cells aren't enough,
let it be +70 at least.


Re: What is this ?! - dominik523 - 28.12.2014

pawn Код:
new string[128];
Done.