SA-MP Forums Archive
Help with register 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: Help with register system (/showthread.php?tid=643307)



Help with register system - 1fret - 17.10.2017

OMG this register system i made it right, and then if i set player A to be an admin it will set and it will save, good.. Now if player B comes online and register he will get the stats of player A, resulting in him also being admin, anyways i then made a resetvariable(playerid);, which is called when the players (dis)connect, now i place this coding under the resetvariable function
PHP код:
pInfo[playerid][Admin] = 0
Which should reset the function for the player which also works, now when player A reconnects he doesn't have the admin status because of the function i have created. It will set the players admin level to 0 resulting he/she not being a server admin anymore...

PHP код:
ResetVariables(playerid)
{
    
PlayerTemp[playerid][OnDuty]   = 0;
    
PlayerTemp[playerid][OnhDuty]  = 0;
    
PlayerTemp[playerid][Spawned]  = 0;
    
PlayerTemp[playerid][isevent]  = 0;
    
PlayerTemp[playerid][MaxRcon]  = 0;
    
PlayerTemp[playerid][Jetpack]  = 0;
    
PlayerTemp[playerid][LastShot] = 0;
    
PlayerTemp[playerid][LastShotTick]  = 0;
       
PlayerTemp[playerid][dSpawnedCars]  = 0;
    
PlayerTemp[playerid][pSpawnFreeze]  = 0;
    
PlayerTemp[playerid][LoginAttempts] = 0;
//these are all that reset to 0 below
    
pInfo[playerid][Score]      = 0;
    
pInfo[playerid][Kills]      = 0;
    
pInfo[playerid][Deaths]      = 0;
    
pInfo[playerid][Banned]      = 0;
    
pInfo[playerid][Admin]      = 0;
/*^^^^^^^^^^^^^^^^^^^^^^^^^*/
    
NeedsHelp[playerid]            = 0;
    
ReportTime[playerid]           = 0;
    
Delete3DTextLabel(afklabel[playerid]);
    
Delete3DTextLabel(adminlabel[playerid]);
  

I have even seen the same pinfo[][] =0; in other admin systems and it doesn't result in what im getting


Re: Help with register system - Escobabe - 17.10.2017

I've had this problem too, and i fixed it by adding all player variables to 0; under OnPlayerConnect when he registeres. Hope this helps.

Here's the example from my script.:

PHP код:
else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
        
GivePlayerMoney(playerid25000);
        
PlayerInfo[playerid][pKills] = 0;
        
PlayerInfo[playerid][pDeaths] = 0;
        
PlayerInfo[playerid][pScore] = 0



Re: Help with register system - Kane - 17.10.2017

Where do you use ResetVariables()?


Re: Help with register system - scripter111 - 17.10.2017

add me in skype gta.abaddon.gta and i will help you


Re: Help with register system - StrikerZ - 17.10.2017

Quote:
Originally Posted by 1fret
Посмотреть сообщение
OMG this register system i made it right, and then if i set player A to be an admin it will set and it will save, good.. Now if player B comes online and register he will get the stats of player A, resulting in him also being admin, anyways i then made a resetvariable(playerid);, which is called when the players (dis)connect, now i place this coding under the resetvariable function
PHP код:
pInfo[playerid][Admin] = 0
Which should reset the function for the player which also works, now when player A reconnects he doesn't have the admin status because of the function i have created. It will set the players admin level to 0 resulting he/she not being a server admin anymore...

PHP код:
ResetVariables(playerid)
{
    
PlayerTemp[playerid][OnDuty]   = 0;
    
PlayerTemp[playerid][OnhDuty]  = 0;
    
PlayerTemp[playerid][Spawned]  = 0;
    
PlayerTemp[playerid][isevent]  = 0;
    
PlayerTemp[playerid][MaxRcon]  = 0;
    
PlayerTemp[playerid][Jetpack]  = 0;
    
PlayerTemp[playerid][LastShot] = 0;
    
PlayerTemp[playerid][LastShotTick]  = 0;
       
PlayerTemp[playerid][dSpawnedCars]  = 0;
    
PlayerTemp[playerid][pSpawnFreeze]  = 0;
    
PlayerTemp[playerid][LoginAttempts] = 0;
//these are all that reset to 0 below
    
pInfo[playerid][Score]      = 0;
    
pInfo[playerid][Kills]      = 0;
    
pInfo[playerid][Deaths]      = 0;
    
pInfo[playerid][Banned]      = 0;
    
pInfo[playerid][Admin]      = 0;
/*^^^^^^^^^^^^^^^^^^^^^^^^^*/
    
NeedsHelp[playerid]            = 0;
    
ReportTime[playerid]           = 0;
    
Delete3DTextLabel(afklabel[playerid]);
    
Delete3DTextLabel(adminlabel[playerid]);
  

I have even seen the same pinfo[][] =0; in other admin systems and it doesn't result in what im getting
Make sure you aren't resetting the variables before saving his/her data on OnPlayerDisconnect.


Re: Help with register system - Prokill911 - 17.10.2017

You should be resetting the value for that playerid on connect, and before login.
so when they login it gets their info
And if they're registering, you should be SETTING everything to default anyway..
So
Код:
 OnRegister(playerid) {  
    pInfo[playerid][Score]      = 0; 
    pInfo[playerid][Kills]      = 0; 
    pInfo[playerid][Deaths]      = 0; 
    pInfo[playerid][Banned]      = 0; 
    pInfo[playerid][Admin]      = 0; 
}



Re: Help with register system - StrikerZ - 17.10.2017

PHP код:
ResetVariables(playerid)
{
    
PlayerTemp[playerid][OnDuty]   = 0;
    
PlayerTemp[playerid][OnhDuty]  = 0;
    
PlayerTemp[playerid][Spawned]  = 0;
    
PlayerTemp[playerid][isevent]  = 0;
    
PlayerTemp[playerid][MaxRcon]  = 0;
    
PlayerTemp[playerid][Jetpack]  = 0;
    
PlayerTemp[playerid][LastShot] = 0;
    
PlayerTemp[playerid][LastShotTick]  = 0;
       
PlayerTemp[playerid][dSpawnedCars]  = 0;
    
PlayerTemp[playerid][pSpawnFreeze]  = 0;
    
PlayerTemp[playerid][LoginAttempts] = 0;
//these are all that reset to 0 below
    
pInfo[playerid][Score]      = 0;
    
pInfo[playerid][Kills]      = 0;
    
pInfo[playerid][Deaths]      = 0;
    
pInfo[playerid][Banned]      = 0;
    
pInfo[playerid][Admin]      = 0;
/*^^^^^^^^^^^^^^^^^^^^^^^^^*/
    
NeedsHelp[playerid]            = 0;
    
ReportTime[playerid]           = 0;
    
Delete3DTextLabel(afklabel[playerid]);
    
Delete3DTextLabel(adminlabel[playerid]);
  

And no need for that, you can do a simple 1 line.
PHP код:
ResetVariables(playerid)
{
   
memcpy(pInfo[playerid], pInfo[MAX_PLAYERS], 0sizeof(pInfo[])*4sizeof(pInfo[]));  
memcpy(PlayerTemp[playerid], PlayerTemp[MAX_PLAYERS], 0sizeof(PlayerTemp[])*4sizeof(PlayerTemp[]));
    
NeedsHelp[playerid]  = 0;
    
ReportTime[playerid] = 0;
    
Delete3DTextLabel(afklabel[playerid]);
    
Delete3DTextLabel(adminlabel[playerid]);




Re: Help with register system - Mado - 17.10.2017

Not the TS but working on a similar system: is resetting these stats absolutely needed? Why can't the '[playerinfo][][admin]' integer be null instead of 0?

I don't question your knowledge on this subject, I am just curious.


Re: Help with register system - StrikerZ - 17.10.2017

Quote:
Originally Posted by Mado
Посмотреть сообщение
Not the TS but working on a similar system: is resetting these stats absolutely needed? Why can't the '[playerinfo][][admin]' integer be null instead of 0?

I don't question your knowledge on this subject, I am just curious.
Resetting the stats is needed.
Suppose, you're ID 0 and you've data in your variables, and you leave the server, your variables aren't reset to zero and another new player joins with ID 0 ( which was same as yours ), so he'll get the same data as yours which aren't saved/loaded.


Re: Help with register system - Mado - 17.10.2017

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Resetting the stats is needed.
Suppose, you're ID 0 and you've data in your variables, and you leave the server, your variables aren't reset to zero and another new player joins with ID 0 ( which was same as yours ), so he'll get the same data as yours which aren't saved/loaded.
Got it. So I have to reset the variables every time a player joins and leaves the server?