SA-MP Forums Archive
Problem With my registration system ! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem With my registration system ! (/showthread.php?tid=619718)



Problem With my registration system ! - Knowinne - 21.10.2016

Hello.

I have some errors making the /register command. I had some errors. Here!

Код:
CMD:register(playerid,params[])
{
    if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already registered and logged in.");
    if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: This account already exists, please use '/login [password]'.");
    if (strlen(params) == 0) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/register [password]'");
    if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Password length must be greater than three characters");
    if (udb_Create(PlayerName2(playerid),params))
	{
    	new file[256],rname[MAX_PLAYER_NAME], tmp3[100];
    	new strdate[20], year,month,day;
		getdate(year, month, day);
		GetPlayerName(playerid,rname,sizeof(rname));
		format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(rname));
     	GetPlayerIp(playerid,tmp3,100);
		dini_Set(file,"ip",tmp3);
//    	dini_Set(file,"password",params);
	    dUserSetINT(PlayerName2(playerid)).("registered",1);
   		format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
		dini_Set(file,"RegisteredDate",strdate);
		dUserSetINT(PlayerName2(playerid)).("loggedin",1);
		dUserSetINT(PlayerName2(playerid)).("banned",0);
		dUserSetINT(PlayerName2(playerid)).("level",0);
	    dUserSetINT(PlayerName2(playerid)).("LastOn",0);
    	dUserSetINT(PlayerName2(playerid)).("money",0);
    	dUserSetINT(PlayerName2(playerid)).("kills",0);
	   	dUserSetINT(PlayerName2(playerid)).("deaths",0);
		dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
		dUserSetINT(PlayerName2(playerid)).("weed",PlayerInfo[playerid][weed]);
		dUserSetINT(PlayerName2(playerid)).("Gang",PlayerInfo[playerid][gang]);
		dUserSetINT(PlayerName2(playerid)).("Condoms",PlayerInfo[playerid][condoms]);
		dUserSetINT(PlayerName2(playerid)).("inalcatraz",PlayerInfo[playerid][inalcatraz]);
	    PlayerInfo[playerid][LoggedIn] = 1;
	    PlayerInfo[playerid][Registered] = 1;
	    SavePlayer(playerid);
		dUserSetINT(PlayerName2(playerid)).("bowner",0);
		dUserSetINT(PlayerName2(playerid)).("bowned",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned2",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner2",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned3",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner3",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned4",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner4",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned5",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner5",0);
	   	dUserSetINT(PlayerName2(playerid)).("Houseid", -255);
		dUserSetINT(PlayerName2(playerid)).("Rentid", -255);
		dUserSetINT(PlayerName2(playerid)).("SpawnX", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnY", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnZ", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnInt", 0);
		LoginPlayer(playerid);
		LoadPlayer(playerid);
	    SendClientMessage(playerid, green, "ACCOUNT: You are now registered, and have been automaticaly logged in");
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		return 1;
	}
    return 1;
}
The error:

Код:
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\filterscripts\RegistrationSystem.pwn(341) : error 012: invalid function call, not a valid address
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\filterscripts\RegistrationSystem.pwn(341) : warning 215: expression has no effect
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\filterscripts\RegistrationSystem.pwn(341) : error 001: expected token: ";", but found ")"
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\filterscripts\RegistrationSystem.pwn(341) : error 029: invalid expression, assumed zero
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\filterscripts\RegistrationSystem.pwn(341) : fatal error 107: too many error messages on one line

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


4 Errors.
The 341 Line:


Код:
if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: This account already exists, please use '/login [password]'.");
Can you help me fixing these errors? Thanks!


Re: Problem With my registration system ! - SyS - 21.10.2016

PlayerName2 is a function? it might be a variable i think.Replace it rname (make sure you put it before this line and also the GetPlayerName(..) too)


Re: Problem With my registration system ! - Knowinne - 21.10.2016

Can you give me the right code for it ?


Re: Problem With my registration system ! - Knowinne - 21.10.2016

Can you give the right code Please? If so, please send me.


Re: Problem With my registration system ! - Knowinne - 21.10.2016

Someone can reply to my question, Please?

Thanks!


Re: Problem With my registration system ! - RockyGamer - 21.10.2016

I think that I've already told you this but i haven't explained it well.

You can't use PlayerName2(playerid) if you don't have it defined so you should either define/stock it or start replacing it with GetPlayerName .

If you decide to replace it this is how to make a stock do this:

pawn Код:
stock PlayerName2(id) // so you have an id argument where you put the wanted players ID when calling the function
{
    new name[16]; // here you're making the empty string where you'll store a players name
    GetPlayerName(id, name, sizeof(name)); // here you're storing it
    return name; // sending player's name as a return
}
and i've already explained replacing it: http://forum.sa-mp.com/showpost.php?...88&postcount=4




Re: Problem With my registration system ! - Knowinne - 21.10.2016

Fixed by myself and you too. Thanks !