Player becomes admin when registers(MYSQL)
#1

Hey,

I have a MySQL system and I found out that there was something wrong. When a new player joins, they become an Admin. I think its when someone joins with the same ID as the previous player, they get the same info or something. But it seems to only happen when they register, I think its fine when you have already registered and are logging in.

Is there a way to fix this?
Reply
#2

Well how are we supposed to fix it without any kind of code.
Reply
#3

Quote:
Originally Posted by FunnyBear
Посмотреть сообщение
I think its when someone joins with the same IP as the previous player, they get the same info or something.
With the same ID not IP. To fix it, reset all variables when aplayer joins the server. Example:

pawn Код:
//OnPlayerConnect

pInfo[playerid][Admin] = 0;
pInfo[playerid][Money] = 0;
Reply
#4

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
With the same ID not IP. To fix it, reset all variables when aplayer joins the server. Example:

pawn Код:
//OnPlayerConnect

pInfo[playerid][Admin] = 0;
pInfo[playerid][Money] = 0;
Or just set them to the new players info once he logs in, he could use something like pInfo[playerid][loggedIn] to check if he should set them yet or alike.
Reply
#5

Are you sure you are resetting the variables upon disconnect? Because if you don't the player that comes after will replace the previous player ID and take his variables.

Example:

Player A logs in the server with his own variables let's say.

pawn Код:
new MyVariable[MAX_PLAYERS];

OnPlayerConnect(playerid) // I've taken this callback as an example it has nothing to do with your issue!
{
MyVariable[playerid] = 1; // Assigned the variable 1 to the following player id. (Let's say 0) So player ID 0 has "MyVariable" set to 1.
}
// Now here comes the Disconnecting part if you don't set it to 0 aka reset the variable the current player will disconnect BUT that variable is still set as true(1) to that playerid! Therefore do the following..

OnPlayerDisconnect(playerid,reason)
{
MyVariable[playerid] = 0;
}
Reply
#6

You dont seem to know your own script very well, so probably you donwloaded it somewhere without reading how to use it, and this bug is actually a wanted function to make yourself admin when setting up the server. So read how to use that script and youll probably find out how to turn that behaviour off.
Reply
#7

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You dont seem to know your own script very well, so probably you donwloaded it somewhere without reading how to use it, and this bug is actually a wanted function to make yourself admin when setting up the server. So read how to use that script and youll probably find out how to turn that behaviour off.
No. It's my server, I don't download other gamemodes. It's just not right

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Are you sure you are resetting the variables upon disconnect? Because if you don't the player that comes after will replace the previous player ID and take his variables.

Example:

Player A logs in the server with his own variables let's say.

pawn Код:
new MyVariable[MAX_PLAYERS];

OnPlayerConnect(playerid) // I've taken this callback as an example it has nothing to do with your issue!
{
MyVariable[playerid] = 1; // Assigned the variable 1 to the following player id. (Let's say 0) So player ID 0 has "MyVariable" set to 1.
}
// Now here comes the Disconnecting part if you don't set it to 0 aka reset the variable the current player will disconnect BUT that variable is still set as true(1) to that playerid! Therefore do the following..

OnPlayerDisconnect(playerid,reason)
{
MyVariable[playerid] = 0;
}
So how do I reset the player variables?
Reply
#8

Quote:
Originally Posted by FunnyBear
Посмотреть сообщение
No. It's my server, I don't download other gamemodes. It's just not right




So how do I reset the player variables?
I doubt if your server if you didn't understand what I've said above however simply set your variable to 0 for example.

pawn Код:
PlayerInfo[playerid][pAdmin] = 0; //
Reply
#9

Quote:
Originally Posted by FunnyBear
Посмотреть сообщение
Hey,

I have a MySQL system and I found out that there was something wrong. When a new player joins, they become an Admin. I think its when someone joins with the same ID as the previous player, they get the same info or something. But it seems to only happen when they register, I think its fine when you have already registered and are logging in.

Is there a way to fix this?
in addition to clearing the variables on OnPlayerDisconnect(..) you should also make the register part write a set of default values into the database.

Perhaps, do something like this:
"INSERT INTO `table` (level, name, money, etc..) VALUES (0, name, 0, etc..)"
.. where you directly write level as 0 and all other values/integers as 0.
Then you will make sure to avoid the incorrect values, at least when registering.
Reply
#10

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
in addition to clearing the variables on OnPlayerDisconnect(..) you should also make the register part write a set of default values into the database.

Perhaps, do something like this:
"INSERT INTO `table` (level, name, money, etc..) VALUES (0, name, 0, etc..)"
.. where you directly write level as 0 and all other values/integers as 0.
Then you will make sure to avoid the incorrect values, at least when registering.
I already have something like that, under stock MySQL_register

pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[300], pname[24], IP[16];
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 16);
    format(query, sizeof(query), "INSERT INTO playerdata (user, password, pAdmin, pWarns, pScore, pMoney, IP, pSeconds, pMinutes, pHours, pKills, pDeaths, pRegister, pVip) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, NOW(), 0)", pname, passwordstring, IP);
    pInfo[playerid][pAdmin] = 0; // just added
   
    mysql_query(query);
    SendClientMessage(playerid, INFO, ">> You have sucesfully registered a new account!");
    Logged[playerid] = 1;
    return 1;
}
So shouldn't it be working already
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)