[GameMode] Blank MySQL R39-3 Gamemode - 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: Gamemode Scripts (
https://sampforum.blast.hk/forumdisplay.php?fid=71)
+--- Thread: [GameMode] Blank MySQL R39-3 Gamemode (
/showthread.php?tid=598270)
Blank MySQL R39-3 Gamemode -
J4Rr3x - 10.01.2016
MySQL
Blank gamemode
Hi all.
Today I've wrote a MySQL blank gamemode, so, there are only the account system. Maybe, in the future, gamemode will be updated by entering houses and vehicles system.
You need:
- a_mysql (
https://sampforum.blast.hk/showthread.php?tid=56564)
- zcmd (
https://sampforum.blast.hk/showthread.php?tid=91354)
- sscanf2 (
https://sampforum.blast.hk/showthread.php?tid=570927)
- BitFlag litte tutorial:
Quote:
Originally Posted by Slice
Bit-flags in enums
Did you know that you can store 32 true/false values in one single variable? Not only do you save space, but you also get less clutter in your code.
You don't have to understand how the binary numeral system works; however, I recommend it. You can read more about it in this topic, if you're interested.
If you have, say, 100 true/false (bool) per-player variables you would use 195 KB of space. However, if you were to use 4 arrays with bit flags, only 8 KB of space would be used. The outcome would be exactly the same, but you would save 187 KB of space!
Here's an example also containing macros to simplify the usage.
pawn Код:
// Usage for all macros: BitFlag_X(variable, flag) #define BitFlag_Get(%0,%1) ((%0) & (%1)) // Returns zero (false) if the flag isn't set. #define BitFlag_On(%0,%1) ((%0) |= (%1)) // Turn on a flag. #define BitFlag_Off(%0,%1) ((%0) &= ~(%1)) // Turn off a flag. #define BitFlag_Toggle(%0,%1) ((%0) ^= (%1)) // Toggle a flag (swap true/false).
enum PlayerFlags:(<<= 1) { // It's important that you don't forget to put "= 1" on the first flag. If you don't, all flags will be 0. PLAYER_IS_LOGGED_IN = 1, // 0b00000000000000000000000000000001 PLAYER_HAS_GANG, // 0b00000000000000000000000000000010 PLAYER_CAN_BUY_PROPERTIES, // 0b00000000000000000000000000000100 PLAYER_BLABLA_1, // 0b00000000000000000000000000001000 PLAYER_BLABLA_2, // 0b00000000000000000000000000010000 PLAYER_BLABLA_3, // 0b00000000000000000000000000100000 PLAYER_BLABLA_4, // 0b00000000000000000000000001000000 PLAYER_BLABLA_5, // 0b00000000000000000000000010000000 PLAYER_BLABLA_6, // 0b00000000000000000000000100000000 PLAYER_BLABLA_7, // 0b00000000000000000000001000000000 PLAYER_BLABLA_8, // 0b00000000000000000000010000000000 PLAYER_BLABLA_9, // 0b00000000000000000000100000000000 PLAYER_BLABLA_10, // 0b00000000000000000001000000000000 PLAYER_BLABLA_11, // 0b00000000000000000010000000000000 PLAYER_BLABLA_12, // 0b00000000000000000100000000000000 PLAYER_BLABLA_13, // 0b00000000000000001000000000000000 PLAYER_BLABLA_14, // 0b00000000000000010000000000000000 PLAYER_BLABLA_15, // 0b00000000000000100000000000000000 PLAYER_BLABLA_16, // 0b00000000000001000000000000000000 PLAYER_BLABLA_17, // 0b00000000000010000000000000000000 PLAYER_BLABLA_18, // 0b00000000000100000000000000000000 PLAYER_BLABLA_19, // 0b00000000001000000000000000000000 PLAYER_BLABLA_20, // 0b00000000010000000000000000000000 PLAYER_BLABLA_21, // 0b00000000100000000000000000000000 PLAYER_BLABLA_22 // 0b00000001000000000000000000000000 };
new // Create an array with the same tag as the enum PlayerFlags:g_PlayerFlags[MAX_PLAYERS] ;
public OnPlayerConnect(playerid) { // 0 - All flags are off (false). You must include the tag to prevent a warning. g_PlayerFlags[playerid] = PlayerFlags:0; }
public OnPlayerLogIn(playerid) { BitFlag_On(g_PlayerFlags[playerid], PLAYER_IS_LOGGED_IN); // Without macros: // g_PlayerFlags[playerid] |= PLAYER_IS_LOGGED_IN; }
public OnPlayerJoinGang(playerid) { BitFlag_On(g_PlayerFlags[playerid], PLAYER_HAS_GANG); // Without macros: // g_PlayerFlags[playerid] |= PLAYER_HAS_GANG; }
public OnPlayerLeaveGang(playerid) { BitFlag_Off(g_PlayerFlags[playerid], PLAYER_HAS_GANG); // Without macros: // g_PlayerFlags[playerid] &= ~PLAYER_HAS_GANG; }
public OnPlayerUpdate(playerid) { // DoSomething every-other player update. BitFlag_Toggle(g_PlayerFlags[playerid], PLAYER_BLABLA_19); if (BitFlag_Get(g_PlayerFlags[playerid], PLAYER_BLABLA_19)) { DoSomething(); } // Without macros: // g_PlayerFlags[playerid] ^= PLAYER_BLABLA_19; // // if (g_PlayerFlags[playerid] & PLAYER_BLABLA_19) { // DoSomething(); // } }
|
Features:
- Account system with MySQL
- Server-side money
- BitFlag instead of boolean variables
- Ban offline player
Download:
-
https://github.com/xL10n/mysql-blank
Re: Blank MySQL R39-3 Gamemode -
OwlIT - 10.01.2016
I didn't look all the code but you have forgotten to replace playerid with %0 in this part:
Код:
#define SendErrorMessage(%0,%1) SendClientMessage(playerid, 0xFF0000, "Error: "%1)
#define SendSyntaxMessage(%0,%1) SendClientMessage(playerid, 0xFF0000, "Syntax: "%1)
However nice work keep it up.
Re: Blank MySQL R39-3 Gamemode - justice96 - 11.01.2016
This is really useful for beginners who wants to start with MySQL. good job my
J!
Re: Blank MySQL R39-3 Gamemode -
Elegy - 11.01.2016
Yes,good for newbie that who wanna make mysql server
Re: Blank MySQL R39-3 Gamemode -
Slawiii - 26.05.2016
very nice for newbies like me
Re: Blank MySQL R39-3 Gamemode -
Logic_ - 27.05.2016
Quote:
Originally Posted by Slawiii
very nice for newbies like me
|
thanks for bumping a old thread.
Re: Blank MySQL R39-3 Gamemode -
N0FeaR - 27.05.2016
Good job, i like it!
Re: Blank MySQL R39-3 Gamemode -
Slawiii - 27.05.2016
Quote:
Originally Posted by ALiScripter
thanks for bumping a old thread.
|
Your Welcome Men
Re: Blank MySQL R39-3 Gamemode -
J4Rr3x - 04.06.2016
Quote:
Originally Posted by N0FeaR
Good job, i like it!
|
Quote:
Originally Posted by Slawiii
very nice for newbies like me
|
Thanks you, men!
Re: Blank MySQL R39-3 Gamemode -
Ritzy2K - 23.06.2016
Quote:
Originally Posted by ALiScripter
thanks for bumping a old thread.
|
give me 1 reason WHY any release threads cannot be bumped?