Getting stupid issues with a simple login system
#1

ok so im trying to set up a rank system based on a players level, im trying to use the y_ini include system to do this.

Код:
public OnPlayerLogin(playerid)
{
	new playername[12];
	new string[64];
	{
	    if (pInfo(playerid)[pAdmin] == 0);
	    {
    	format(string,sizeof string,"Player %s has joined the server.",playername);
    	SendClientMessageToAll(0xFFFFFFAA,string);
    	}
		else if(pInfo(playerid)[pAdmin] == 1);
	    {
	    format(string,sizeof string,"Applicant %s has joined the server.",playername);
  		SendClientMessageToAll(0xFFFFFFAA,string);
		}
		else if(IsPlayerAdmin(playerid) == 2);
 		{
 		format(string,sizeof string,"Cadet %s has joined the server.",playername);
    	SendClientMessageToAll(0xFFFFFFAA,string);
    	}
		else if(IsPlayerAdmin(playerid) == 3);
 		{
    	format(string,sizeof string,"Admin %s has joined the server.",playername);
    	SendClientMessageToAll(0xFFFFFFAA,string);
    	}
		else if(IsPlayerAdmin(playerid) == 4);
    	{
    	format(string,sizeof string,"Server Tech %s has joined the server.",playername);
    	SendClientMessageToAll(0xFFFFFFAA,string);
    	}
		else if(IsPlayerAdmin(playerid) == 5);
    	{
    	format(string,sizeof string,"Owner %s has joined the server.",playername);
   	SendClientMessageToAll(0xFFFFFFAA,string);
    	}
	}
}
Unfortunately i keep getting this as an error mesage.

Quote:

C:\Users\Deshon\Desktop\My Servers\Server 0.3z\gamemodes\Revival-Copy.pwn(1230) : error 012: invalid function call, not a valid address
C:\Users\Deshon\Desktop\My Servers\Server 0.3z\gamemodes\Revival-Copy.pwn(1230) : warning 215: expression has no effect
C:\Users\Deshon\Desktop\My Servers\Server 0.3z\gamemodes\Revival-Copy.pwn(1230) : error 001: expected token: ";", but found ")"
C:\Users\Deshon\Desktop\My Servers\Server 0.3z\gamemodes\Revival-Copy.pwn(1230) : error 029: invalid expression, assumed zero
C:\Users\Deshon\Desktop\My Servers\Server 0.3z\gamemodes\Revival-Copy.pwn(1230) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

I do not claim to be a scripting whiz. All the codes work for my Login/Register system and i have all the necessary definitions n such, i just dont know. Also dont mind anything past Level 0, i was messing with some other ideas.

Any help would be appreciated thanks.
Reply
#2

You are stopping each if and each else if before it could start.
Never place a semicolon after:
pawn Код:
if(code here)
else if(code here)
You didn't give sizeof a value.
It should be:
pawn Код:
format(string, sizeof(string), "blablabla", playername);
You opened the function brackets after new string[64];
Local variables don't require to open brackets.

pawn Код:
new playername[12], string[64];
    if (pInfo(playerid)[pAdmin] == 0)
    {
        format(string,sizeof(string),"Player %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
I fixed the mistakes and the indentation.

pawn Код:
public OnPlayerLogin(playerid)
{
    new playername[12], string[64];
    if (pInfo(playerid)[pAdmin] == 0)
    {
        format(string,sizeof(string),"Player %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 1)
    {
        format(string,sizeof(string),"Applicant %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(IsPlayerAdmin(playerid) == 2)
    {
        format(string,sizeof(string),"Cadet %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(IsPlayerAdmin(playerid) == 3)
    {
        format(string,sizeof(string),"Admin %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(IsPlayerAdmin(playerid) == 4)
    {
        format(string,sizeof(string),"Server Tech %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(IsPlayerAdmin(playerid) == 5)
    {
        format(string,sizeof(string),"Owner %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    return 1;
}
Reply
#3

Thanks for that, solved a potential future problem, but it still didnt really solve my current problem. same error.

Here, i even updated the script a bit.

Код:
public OnPlayerLogin(playerid)
{
    new playername[12], string[64];
    if (pInfo(playerid)[pAdmin] == 0)
    {
        format(string,sizeof(string),"Player %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 1)
    {
        format(string,sizeof(string),"Applicant %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 2)
    {
        format(string,sizeof(string),"Cadet %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 3)
    {
        format(string,sizeof(string),"Admin %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 4)
    {
        format(string,sizeof(string),"Server Tech %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    else if(pInfo(playerid)[pAdmin] == 5)
    {
        format(string,sizeof(string),"Owner %s has joined the server.",playername);
        SendClientMessageToAll(0xFFFFFFAA,string);
    }
    return 1;
}
Reply
#4

pInfo(playerid)[pAdmin] is nearly correct. The problem is (playerid), you should use '[' and ']' instead of '(' and ')'. Example:
pawn Код:
pInfo(playerid)[pAdmin] //wrong
//
pInfo[playerid][pAdmin] //correct
//
I hope this solves the issue
Reply
#5

Playerid after pInfo should be in an array.

pawn Код:
pInfo[playerid][pAdmin]
EDIT: I didn't notice that mistake at first.
I just noticed another mistake, you don't get the player's name. You just get a string, which is in this case %s

Add this under the local variables:
Код:
GetPlayerName(playerid, playername, sizeof(playername));
Reply
#6

Ive tried both options and im still getting the same error. Not much more i can say, if yall need any more info just ask.
Reply
#7

Did you read my edit on my last post?

If yes, can you give us your updated version and show us which line 1230 is.
Reply
#8

yes i read the last post, but i get the players name from the pInfo which is defined in the global variables.
Reply
#9

Can you show me your updated version plus tell me which line 1230 is?
Reply
#10

Quote:
Originally Posted by KingOfStarfox
Посмотреть сообщение
yes i read the last post, but i get the players name from the pInfo which is defined in the global variables.
Show me the global variable you're talking about as well as your updated version of OnPlayerLogin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)