SA-MP Forums Archive
Newbie need some help with his scripts - 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: Newbie need some help with his scripts (/showthread.php?tid=394796)



Newbie need some help with his scripts - Zex Tan - 24.11.2012

Код:
CMD:ban(playerid, params[])
{
    new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
	new id, reason[126];
	if (sscanf(params, "us[126]", id, reason))
	    return SendClientMessage (playerid, -1, "Usage: /ban [ID] [reason]");
 	GetPlayerName(playerid, name, sizeof(name));
 	format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", name, id, name, id, reason);
	SendClientMessageToAll(RED, string);
	Ban(id);
	return 1;
}
Well , there is no errors but when I was IG there is an error I did .

Server shows
Код:
[10:13:24] {FFFFFF}SA-MP {B9B9BF}0.3e {FFFFFF}Started

[10:13:27] Connecting to 10.1.1.34:7777...

[10:13:31] Connected. Joining the game...

[10:13:31] Connected to {B9B9BF}Castaway Island Test

[10:13:39] <Steven_Colt> Hello

[10:13:43] Usage: /ban [ID] [reason]

[10:13:53] Steven_Colt(0) was banned from the server by BLA

[10:13:54] Server closed the connection.
Planning to do
Код:
Steven_Colt(0) was banned from the server by Steven_Colt(0). Reason : BLA
Can anyone help me with this ?


Re: Newbie need some help with his scripts - SwisherSweet - 24.11.2012

looks all good i don't see a problem?


Respuesta: Newbie need some help with his scripts - WCrimson - 24.11.2012

pawn Код:
CMD:ban(playerid, params[])
{
    new name[2][MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
    new id, reason[126];
    if (sscanf(params, "us[126]", id, reason))
        return SendClientMessage (playerid, -1, "Usage: /ban [ID] [reason]");
    if( id == playerid ) return 1; //<-------- ?
    GetPlayerName(playerid, name[0], sizeof(name));
    GetPlayerName( id,name[1], sizeof name );
    format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", name[1], id, name[0], playerid, reason);
    SendClientMessageToAll(RED, string);
    Ban(id);
    return 1;
}



Re: Newbie need some help with his scripts - Zex Tan - 24.11.2012

Quote:
Originally Posted by Aveger
Посмотреть сообщение
looks all good i don't see a problem?
What I mean is that I am trying to ban myself and it shows banned by BLA (BLA actually is the reason of ban )


Re: Newbie need some help with his scripts - [HK]Ryder[AN] - 24.11.2012

pawn Код:
CMD:ban(playerid, params[])
{
    new name[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME + 1], string[24+MAX_PLAYER_NAME+1];
    new id, reason[126];
    if (sscanf(params, "us[126]", id, reason)) return SendClientMessage (playerid, -1, "Usage: /ban [ID] [reason]");
    GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(id, pname, sizeof(pname));
    format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", pname, id, name, playerid, reason);
    SendClientMessageToAll(RED, string);
    Ban(id);
    return 1;
}



Re: Newbie need some help with his scripts - Zex Tan - 24.11.2012

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
pawn Код:
CMD:ban(playerid, params[])
{
    new name[MAX_PLAYER_NAME+1], pname[MAX_PLAYER_NAME + 1], string[24+MAX_PLAYER_NAME+1];
    new id, reason[126];
    if (sscanf(params, "us[126]", id, reason)) return SendClientMessage (playerid, -1, "Usage: /ban [ID] [reason]");
    GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(id, pname, sizeof(pname));
    format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", pname, id, name, playerid, reason);
    SendClientMessageToAll(RED, string);
    Ban(id);
    return 1;
}
Still the same ....

It shows "Steven_Colt(0) was banned from the server by Ste" and thats all . Don't know what happen to the scripts .


Re: Newbie need some help with his scripts - Zex Tan - 24.11.2012

It shows this http://imgur.com/TZYLB


Re: Newbie need some help with his scripts - Ryox175 - 24.11.2012

I dont know how mutch it works.
pawn Код:
//Ban Command
    if(strcmp("/ban", cmd, true) == 0)
    {
        if(IsPlayerAdmin(playerid)) {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 5) {
                return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /ban (id) [reason]");
            }

            new id = strval(tmp);

            if(!IsPlayerConnected(id)) {
                SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : Bad player ID");
                return 1;
            }

            gMessage = strrest(cmdtext,idx);

            GetPlayerName(id,iName,sizeof(iName));
            SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been banned from the server.");

            if(strlen(gMessage) > 0) {
                format(Message,sizeof(Message),"Reason: %s",gMessage);
                SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
            }

            format(Message,sizeof(Message),">> %s(%d) has been banned.",iName,id);
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);

            Ban(id);
            return 1;
        } else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : You are not an admin");
            return 1;
        }
    }
   
    return 0;
}



Re: Newbie need some help with his scripts - Zex Tan - 24.11.2012

Quote:
Originally Posted by Ryox175
Посмотреть сообщение
I dont know how mutch it works.
pawn Код:
//Ban Command
    if(strcmp("/ban", cmd, true) == 0)
    {
        if(IsPlayerAdmin(playerid)) {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 5) {
                return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /ban (id) [reason]");
            }

            new id = strval(tmp);

            if(!IsPlayerConnected(id)) {
                SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : Bad player ID");
                return 1;
            }

            gMessage = strrest(cmdtext,idx);

            GetPlayerName(id,iName,sizeof(iName));
            SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been banned from the server.");

            if(strlen(gMessage) > 0) {
                format(Message,sizeof(Message),"Reason: %s",gMessage);
                SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
            }

            format(Message,sizeof(Message),">> %s(%d) has been banned.",iName,id);
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);

            Ban(id);
            return 1;
        } else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/ban : You are not an admin");
            return 1;
        }
    }
   
    return 0;
}
Dude,
Код:
    format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", pname, id, name, playerid, reason); //there is something wrong here I guess



Re: Newbie need some help with his scripts - Ryox175 - 24.11.2012

Quote:
Originally Posted by Zex Tan
Посмотреть сообщение
Dude,
Код:
    format(string, sizeof(string), "%s(%d) was banned from the server by %s(%d). Reason: %s .", pname, id, name, playerid, reason); //there is something wrong here I guess
i tested with filterscript try it as filterscript.