[HELP]Stopping People Using The Server's [TAG]
#1

Hello,
I'm Currently Scripting My Own Game-mode. I Decided To Write A Piece Of Code Designed To Stop People From Connecting To The Server With The Server's [TAG]. I've Defined PlayerInfo Since Most Of My Game-mode Variables Are pInfo..

Here Is What I've Come Up With...
Code:
public OnPlayerConnect(playerid)
{
	if(PlayerInfo[playerid][TagPerm] >= 0)
	{
	    new tName[24];
	    new PlayerName[MAX_PLAYER_NAME];
	    GetPlayerName(playerid,tName, 24);
	    GetPlayerName(playerid,PlayerName, 24);
	    if(PlayerName == "[TAG]%s",tName); // 369
	    {
	           SendClientMessageToAll(COLOR_GREY,"%s(%d)Kicked Because TAG Permission Hasn't Been Given To Them",tName,playerid); //371
	           Kick(playerid);
	    }
	}
	return 1;
}
Errors:
Code:
(369) : error 033: array must be indexed (variable "PlayerName")
(369) : error 036: empty statement
(371) : warning 202: number of arguments does not match definition
(371) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Hopefully I Can Get This To Work With Your Help!

Kind Regards,
Kensington
Reply
#2

Everything about your code is really fucked up...

Firstly... if TagPerm is zero or higher (basically in every case, except below zero)

Secondly, why do you use two times GetPlayerName?

Thirdly, instead of this if(PlayerName == "[TAG]%s",tName); (Also there shouldn't be semicolon at the end) use strcmp method.

Quarterly, the message needs to be formatted.

And finally, why do you capitalize every letter of every word?
Reply
#3

Quote:
Originally Posted by iMonk3y
View Post
Everything about your code is really fucked up...

Firstly... if TagPerm is zero or higher (basically in every case, except below zero)

Secondly, why do you use two times GetPlayerName?

Thirdly, instead of this if(PlayerName == "[TAG]%s",tName); (Also there shouldn't be semicolon at the end) use strcmp method.

Quarterly, the message needs to be formatted.

And finally, why do you capitalize every letter of every word?
1 = True.
0 = False.

Thinking That Would Be Working Fine...

I Added 2 Different GetPlayerNames With 2 Different Values Because I Didn't Want Them Getting Muddled Up... E.G Getting The KillerID and PlayerID - 2 Different Things.. I Tried Looking At The Wiki But I Had Problems Connecting To The Forums And The Wiki.

Please May You Show Me How It's Done?

P.S.. I Capitalize Every Letter Of Every Word In Forums Because Personally I Think It Looks Neater. When It Comes To Writing: I write like this!
Reply
#4

You can't send a string like that, you need to format it. You also can't use if with strings!

https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/Strcmp
Reply
#5

Quote:
Originally Posted by Kensington
View Post
1 = True.
0 = False.

Thinking That Would Be Working Fine...
Why not use boolean?

The code:
pawn Code:
{
    new name [ MAX_PLAYER_NAME ];
    GetPlayerName ( playerid, name, MAX_PLAYER_NAME );
    if( !strcmp( name, "[TAG]", true, 5 )) //Note number 5 - length of a string. First 5 chars will be compared with name... there's probably a better way to do this...
    {
        new str[128];
        format(str, 128,"%s(%d) has been whatever blah blah...", name, playerid);
        SendClientMessageToAll(COLOR_GREY,str);
        SetPlayerName(playerid, "Ebanatyi_Pidaraz");
        Kick(playerid);
    }
}
Reply
#6

Either Way Having A 0 Or 1 Still Kicks Me From The Server :L
Reply
#7

pawn Code:
if(PlayerInfo[playerid][TagPerm] >= 0)
That means if TagPerm is ZERO or ABOVE, should be:

pawn Code:
if(PlayerInfo[playerid][TagPerm] == 0)
Reply
#8

Same Problem - Btw It Was Always == I Copied It From My Admin Command Because I Felt Lazy :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)