ban playerid
#1

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.
Reply
#2

Use strcmp.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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;
}
Reply
#6

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 -.-
Reply
#7

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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)