Registry help?
#1

ok, i FINALLY made a registration script, i want to make it so if a new player joins, it says Welcome please register, but also check if the player has registered before, if so saying Automaticly logged in!


my code.
Код:
new name[MAX_PLAYER_NAME];
	tmp = strtok(cmdtext, idx);
	GetPlayerName(playerid, name, sizeof(name));
	if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
	format(file,sizeof(file),"%s.ini",name);
Reply
#2

This would be OnPlayerConnect

Код:
new name[MAX_PLAYER_NAME],file[23];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"%s.ini");
if(fexist(file))
{
SendClientMessage(playerid,0xFFFFFF,"Welcome back! You have been automatically logged in!");
//Load the stuff
return 1;
}
if(!fexist(file))
{
SendClientMessage(playerid,0xFFFFFF,"You have not been registered! Please use /register");
return 1;
}
But i would not recommend using this as other players just needs to know the name of a player to gain hes stats. You could tho save the players IP on register and check if its the same
Reply
#3

How would i do that?
Reply
#4

Place this in the register command

Код:
new IP[16];
GetPlayerIp(playerid,IP,sizeof(IP));
dini_IntSet(file,"PlayerIP",IP);
This saves the players IP in the dini


under onplayerconnect

Код:
//Make sure it has checked if it has checked if the file exists at this point
new IP[16],IP2[16];
GetPlayerIP(playerid,IP,sizeof(ip));
IP2 = dini_Int(file,"PlayerIP");
if(IP == IP2)
{
//Add the auto login stuff here from before
return 1;
}
else return SendClientMessage(playerid,0xFFFFFF,"You have already registered an account. But IP did not match! Please login");
}
Now i would recommend changing IP at login if case the player got a new PC or moved or any other reason he got a new IP. Use the same as in the register command for this
Reply
#5

Thanks!
Reply
#6

now i got a problem D:


Код:
public OnPlayerConnect(playerid)
{
new IP[16];
new IP2[16];
GetPlayerIp(playerid,IP,sizeof(IP));
IP2 = dini_Int(file,"PlayerIP");
if(IP == IP2)
{
new name[MAX_PLAYER_NAME],file[23];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"%s.ini");
if(fexist(file))
{
SendClientMessage(playerid,0xFFFFFF,"Welcome back! You have been automatically logged in!");
return 1;
}
else return SendClientMessage(playerid,0xFFFFFF,"You have already registered an account. But IP did not match! Please login");
}
Reply
#7

Try this one

Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME],file[23];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"%s.ini");
if(fexist(file))
{
new IP[16];
new IP2[16];
GetPlayerIp(playerid,IP,sizeof(IP));
IP2 = dini_Int(file,"PlayerIP");
if(IP == IP2)
{
SendClientMessage(playerid,0xFFFFFF,"Welcome back! You have been automatically logged in!");
return 1;
}
else return SendClientMessage(playerid,0xFFFFFF,"You have already registered an account. But IP did not match! Please login");
}
else return SendClientMessage(playerid,0xFFFFFF,"Welcome! Please register an account");
}
Reply
#8

Код:
C:\Users\Documents\pawno\new.pwn(68) : error 033: array must be indexed (variable "IP2")
C:\Users\Documents\pawno\new.pwn(69) : error 033: array must be indexed (variable "IP")
C:\Users\Documents\pawno\new.pwn(78) : error 010: invalid function or declaration
C:\Users\Documents\pawno\new.pwn(130) : error 035: argument type mismatch (argument 3)
Are the errors i get

Reply
#9

anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)