IP Join script
#1

I have made this script with the intention to display the IP of a player when he connects
Код:
public OnPlayerConnect(playerid)
{
	new name[MAX_PLAYER_NAME], string[128];
	new para1, ip[17];
	
	GetPlayerName(para1, name, sizeof(name));
	GetPlayerIp(para1, ip, sizeof(ip));
	
	if(Player[playerid][pAdmin] >= 1 && IsPlayerAdmin(playerid))
	format(string, sizeof(string), "[ADMIN] Player %s has connected with IP: %d", name, ip);
	SendAdminMessage(-1, string);
	return 1;
}
the message is not shown however, why would that be?

Also, my givegun script is acting weird - I have put:
Код:
	if(!( 1 <= ammo <= 999 )) 
		return SCM(playerid, -1, "The gun ammo must be between 1-999!");
But if I put in a value between 1-999 (e.g 500) it says it the ammo must be between 1-999.
I have seen this in the server console: sscanf warning: Format specifier does not match parameter count.
What does this mean?
Reply
#2

Код:
GetPlayerIP(playerid,ip,sizeof(ip));
Код:
if(ammo == 0 || ammo >= 999) return SCM(playerid,-1,"The gun ammo must be between 1-999!");
Reply
#3

I don't know if you realized it yet, but this:
PHP код:
if(Player[playerid][pAdmin] >= && IsPlayerAdmin(playerid)) 
means, you have to be atleast an admin and logged into rcon.
PHP код:
if(Player[playerid][pAdmin] >= || IsPlayerAdmin(playerid)) 
I recommend you to use this.
Reply
#4

Try this and let me know what happens :
PHP код:
public OnPlayerConnect(playerid)
{
    new 
name[MAX_PLAYER_NAME], string[128];
    new 
ip[17];
    
GetPlayerName(playeridnamesizeof(name));
    
GetPlayerIp(playeridipsizeof(ip));
    if(
Player[playerid][pAdmin] >= || IsPlayerAdmin(playerid))
    {
        
format(stringsizeof(string), "[ADMIN] Admin Player %s has connected with IP: %s"nameip);
        
SendAdminMessage(-1string);
    }
    else
    {
        
format(stringsizeof(string), "[ADMIN] Player %s has connected with IP: %s"nameip);
        
SendAdminMessage(-1string);
    }
    return 
1;

Also, I give an usefull function called "GetName(playerid)" which return the name of the player. Take a look:
PHP код:
stock GetName(playerid)
{
    new 
GeName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridGeNamesizeof(GeName));
    return 
GeName;
}
public 
OnPlayerConnect(playerid)
{
    new 
string[128], ip[17];
    
GetPlayerIp(playeridipsizeof(ip));
    if(
Player[playerid][pAdmin] >= || IsPlayerAdmin(playerid))
    {
        
format(stringsizeof(string), "[ADMIN] Admin Player %s has connected with IP: %s"GetName(playerid), ip);
        
SendAdminMessage(-1string);
    }
    else
    {
        
format(stringsizeof(string), "[ADMIN] Player %s has connected with IP: %s"GetName(playerid), ip);
        
SendAdminMessage(-1string);
    }
    return 
1;

Reply
#5

IP Adresses are strings not integers.
Reply
#6

Quote:
Originally Posted by Jamester
Посмотреть сообщение
IP Adresses are strings not integers.
But if I do not put arrays in my ip variable it will give me an error, which is:
Код:
GM.pwn(179) : error 035: argument type mismatch (argument 2)
GM.pwn(179) : error 035: argument type mismatch (argument 2)
lines 179:
Код:
 GetPlayerName(playerid, name, sizeof(name)); 
    GetPlayerIp(playerid, ip, sizeof(ip));
Also, what does this mean?
Код:
sscanf warning: Format specifier does not match parameter count.
it is the reason why my givegun script is not working.
Reply
#7

You can't get 2 times 179 lines if they are separate.
The sscanf error is due because you haven't specified the size of your string. Like "is" -> false"is[24]" -> correct
Reply
#8

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
You can't get 2 times 179 lines if they are separate.
The sscanf error is due because you haven't specified the size of your string. Like "is" -> false"is[24]" -> correct
Код:
new para1, gun, ammo;
	new sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], string[128];
is this what you mean ? i have it already
Reply
#9

Quote:
Originally Posted by JXF
Посмотреть сообщение
Код:
new para1, gun, ammo;
	new sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME], string[128];
is this what you mean ? i have it already
Код:
new Target, String[50];
if(sscanf(params, "us[50]", Target, String)) ...
Reply
#10

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Код:
new Target, String[50];
if(sscanf(params, "us[50]", Target, String)) ...
it would have to be "ud" because s = string, and I have weapon ids and ammo in my givegun script
ud[50] does not work either.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)