SA-MP Forums Archive
ban playerid - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ban playerid (/showthread.php?tid=95762)



ban playerid - BP13 - 04.09.2009

whast the function for example

OnPlayerConnect

if playername(playerid = KimSinSeN ban playerid. dont know the exact think do do something if someones name is a certian thing.


Re: ban playerid - Correlli - 04.09.2009

Use strcmp.


Re: ban playerid - BP13 - 04.09.2009

Quote:
Originally Posted by Don Correlli
Use strcmp.
umm like

public OnPlayerConnect(playerid)
{
if(playername, playerid = KimSinSeN
ban(playerid);
}

something like that. but thats probly not right but im not sure how to make it right.


Re: ban playerid - Zezombia - 04.09.2009

Quote:
Originally Posted by Seif_ [adream-rp.com
]
It returns 0 if they're the same and 1 if not.
Actually no. strcmp can return 1 or -1 if they do not compair. Not sure why.


Re: ban playerid - BP13 - 04.09.2009

thanks guys. Would this work

pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof pname);
    if (!strcmp(pname, "KimSinSeN", true)) return Ban(playerid);
    format(string, sizeof(string), "%s Has Been Banned By Console", pName);
    return 1;
}



Re: ban playerid - DMSOrg - 04.09.2009

That wouldn't work

Код:
public OnPlayerConnect(playerid)
{
	new pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, sizeof pname);
	if (!strcmp(pname, "KimSinSeN", true))
    { 
      Ban(playerid);
	  format(string, sizeof(string), "%s Has Been Banned By Console", pName);
      return 1;
    }
    return 1;
}
that would, minus the loose indentation -.-


Re: ban playerid - JaTochNietDan - 04.09.2009

Quote:
Originally Posted by Seif_ [adream-rp.com
]
Quote:
Originally Posted by [SU
BP13 ]
Quote:
Originally Posted by Don Correlli
Use strcmp.
umm like

public OnPlayerConnect(playerid)
{
if(playername, playerid = KimSinSeN
ban(playerid);
}

something like that. but thats probly not right but im not sure how to make it right.
strcmp is a function to compare 2 strings. It returns 0 if they're the same and 1 if not. So basically you'd do this:
pawn Код:
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof pname);
    if (!strcmp(pname, "KimSinSeN", true)) return Ban(playerid);
    return 1;
}
It doesn't return 1, it returns the amount of characters that are not equal in the other string, so comparing "" and "hi" and it returning 0 is not a bug, since there are 0 characters to compare.


Re: ban playerid - BP13 - 04.09.2009

Concluded:

pawn Код:
public OnPlayerConnect(playerid)
{
    new string [128];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof pName);
    ////////////////////////////////////////////
    if (!strcmp(pName, "KimSinSeN", true))
    {
      SendClientMessage(playerid, COLOR_RED, "You Have Been Banned By Console You Moron! Haha!");
        Ban(playerid);
      format(string, sizeof(string), "%s Has Been Banned By Console", pName);
    return 1;
    }
That compiles