05.08.2019, 13:20
Quote:
This is a very basic script, this is more easy for newbies to learn MySQL easily. Who cares if you are a good scripter, learn to respect other works.
No Hate!! Just Truth. Good work GTLS. |
Mysql connection wasn't close at OnGameModeExit.
Player Name is stored in database but no idea why it was not used in script instead using GetPlayerName everytime!
`Users` and `USERS` should be `users` in onplayerconnect and OnPlayerDisconnect callback!
There is no need to login after the player register. It can be done by
pawn Code:
forward OnPlayerRegister(playerid);
public OnPlayerRegister(playerid)
{
pInfo[playerid][MasterID] = cache_insert_id();
pInfo[playerid][PX] = 1527.85;
pInfo[playerid][PY] = -1675.35;
pInfo[playerid][PZ] = 13.3828;
pInfo[playerid][ROOT] = 270;
pInfo[playerid][Skin] = 1;
pInfo[playerid][Level] = 1;
SetPlayerScore(playerid, pInfo[playerid][Level]);
SetSpawnInfo(playerid, 0, pInfo[playerid][Skin], pInfo[playerid][PX], pInfo[playerid][PY], pInfo[playerid]
[PZ],pInfo[playerid][Rot], 0, 0, 0, 0, 0, 0);
SendClientMessage(playerid, 0x0033FFFF /*Blue*/, "Thank you for registering! You will be spawned now!");
TogglePlayerSpectating(playerid, false);
TogglePlayerControllable(playerid, true);
SpawnPlayer(playerid);
return 1;
}
When player disconnect, you should check if player logged in (after login/register) , so the data will be saved in mysql.
What if a player logins with an another player name and exist the server (Calls OnPlayerDisconnect)? or what if a player mistype his password and kicked out?
It will save the player's current position and will be stored into the database under the player name. So, that's why the script needs a login variable.
Anyways Good work!