[GameMode] Very Basic Script
#22

Quote:
Originally Posted by SiaReyes
View Post
Kane was right, if you had read the whole script, you could have spotted some issues.

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;
}
And the last thing is , No Login detection was checked when player disconnect and no player variable for login check is defined.
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!
Quote:
Originally Posted by GeorgeMcReary
View Post
MySQL is not case sensitive lmao.. USERS and users and uSeRs are considered same. About login, Its nothing wrong. A lot of servers and even lots of websites asks for login after register. Doesnt directly logs them in. It depends on everyone's style hahah..

About login variable, I agree with you.... There should be a Login Check variable so that there is no issue.

about closing connection, I think when server is not active, it will kill off the connection automatically... but doesnt hurt adding it there.
I over looked some details but I have fixed them now. Thank you guys for the appreciation and criticism. Criticism makes someone always better.

1> Fixed connection not closed and added saving data OnGameModeExit too.
2> Added Login check- Thanks to SiaReyes. I knew I was forgetting something.. thanks for reminding me..
3> Well yeah, about login thing... Its my way of showing Login dialog after registering. Everyone's way is different as GeorgeMcReary said..
4> Player name is saved in database for login purposes. I dont save them from database on a variable because it looks stupid to me. Again, everyone's way is different. Someone saves them into variable each time player logs in, someone uses GetPlayerName.. none methods are wrong.

No harm done. I always accept criticism, and take it positively.
Reply


Messages In This Thread
Very Basic Script - by GTLS - 23.07.2019, 16:55
Re: Very Basic Script - by N4Sti - 23.07.2019, 17:22
Re: Very Basic Script - by ZigGamerx - 23.07.2019, 17:26
Re: Very Basic Script - by NeXTGoD - 23.07.2019, 18:04
Re: Very Basic Script - by GTLS - 24.07.2019, 04:06
Re: Very Basic Script - by ZigGamerx - 24.07.2019, 09:18
Re: Very Basic Script - by GTLS - 24.07.2019, 10:04
Re: Very Basic Script - by GeorgeMcReary - 24.07.2019, 10:20
Re: Very Basic Script - by Mobtiesgangsa - 24.07.2019, 19:59
Re: Very Basic Script - by Kane - 24.07.2019, 21:18
Re: Very Basic Script - by kukboy - 24.07.2019, 21:48
Re: Very Basic Script - by Josh_Main - 25.07.2019, 08:59
Re: Very Basic Script - by GTLS - 25.07.2019, 09:23
Re: Very Basic Script - by Huemerson - 25.07.2019, 12:49
Re: Very Basic Script - by sonn51280 - 25.07.2019, 13:10
Re: Very Basic Script - by ZigGamerx - 25.07.2019, 14:02
Re: Very Basic Script - by GTLS - 27.07.2019, 09:23
Re: Very Basic Script - by PhantomThief1412 - 04.08.2019, 14:36
Re: Very Basic Script - by ZigGamerx - 04.08.2019, 18:39
Re: Very Basic Script - by SiaReyes - 05.08.2019, 13:20
Re: Very Basic Script - by GeorgeMcReary - 05.08.2019, 16:09
Re: Very Basic Script - by GTLS - 05.08.2019, 16:27
Re: Very Basic Script - by SiaReyes - 05.08.2019, 16:35
Re: Very Basic Script - by Calisthenics - 05.08.2019, 17:16
Re: Very Basic Script - by GTLS - 06.08.2019, 06:59
Re: Very Basic Script - by Calisthenics - 06.08.2019, 08:04
Re: Very Basic Script - by GTLS - 06.08.2019, 08:58
Re: Very Basic Script - by Calisthenics - 06.08.2019, 11:59
Re: Very Basic Script - by GTLS - 07.08.2019, 16:47
Re: Very Basic Script - by Mugala - 08.08.2019, 23:21

Forum Jump:


Users browsing this thread: 1 Guest(s)