-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ON UPDATE NO ACTION - revamp army module
- Loading branch information
1 parent
31f6be4
commit 1cf3438
Showing
17 changed files
with
89 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <YSI_Coding\y_hooks> | ||
|
||
static | ||
BitArray:PlayerIsArmy<MAX_PLAYERS>; | ||
|
||
hook OnPlayerConnect(playerid) { | ||
Bit_Set(PlayerIsArmy, playerid, false); | ||
return 1; | ||
} | ||
|
||
hook OnPlayerLogin(playerid) { | ||
static | ||
Statement:stmt_isArmy; | ||
|
||
inline const OnArmyLoad() { | ||
if(MySQL_Statement_FetchRow(stmt_isArmy)) { | ||
Bit_Set(PlayerIsArmy, playerid, true); | ||
} | ||
} | ||
|
||
stmt_isArmy = MySQL_PrepareStatement(MySQL_GetHandle(), "SELECT 1 FROM armys WHERE u_id = ?"); | ||
MySQL_BindInt(stmt_isArmy, 0, Player_GetAccountID(playerid)); | ||
MySQL_ExecuteParallel_Inline(stmt_isArmy, using inline OnArmyLoad); | ||
return 1; | ||
} | ||
|
||
hook OnPlayerRequestSpawn(playerid) { | ||
if(Player_GetClass(playerid) == TEAM_ARMY) { | ||
if(!Player_IsArmy(playerid)) { | ||
SendErrorMsg(playerid, "No permission to play as army"); | ||
return ~0; | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
stock Player_AddToArmyDB(playerid) { | ||
Player_SetArmy(playerid, true); | ||
|
||
new stmt_insertArmy = MySQL_PrepareStatement(MySQL_GetHandle(), "INSERT INTO armys (u_id) VALUES (?)"); | ||
MySQL_BindInt(stmt_insertArmy, 0, Player_GetAccountID(playerid)); | ||
MySQL_ExecuteThreaded(stmt_insertArmy); | ||
MySQL_StatementClose(stmt_insertArmy); | ||
} | ||
|
||
Player_IsArmy(playerid) { | ||
return Bit_Get(PlayerIsArmy, playerid); | ||
} | ||
|
||
stock Player_SetArmy(playerid, bool:toggle) { | ||
Bit_Set(PlayerIsArmy, playerid, toggle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
CREATE TABLE IF NOT EXISTS admins ( | ||
u_id INT(11) NOT NULL, | ||
admin_level TINYINT(2) NOT NULL DEFAULT 0, | ||
PRIMARY KEY (u_id), | ||
FOREIGN KEY (u_id) REFERENCES players(u_id) | ||
ON DELETE CASCADE | ||
ON UPDATE CASCADE | ||
PRIMARY KEY | ||
(u_id), | ||
FOREIGN KEY | ||
(u_id) | ||
REFERENCES | ||
players(u_id) | ||
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE armys ( | ||
u_id int(11) NOT NULL, | ||
PRIMARY KEY | ||
(u_id), | ||
FOREIGN KEY | ||
(u_id) | ||
REFERENCES | ||
players (u_id) | ||
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ CREATE TABLE IF NOT EXISTS jailed ( | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
RESTRICT | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,5 @@ CREATE TABLE player_items ( | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
CASCADE | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,5 @@ CREATE TABLE IF NOT EXISTS player_shots_stats ( | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
CASCADE | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ CREATE TABLE IF NOT EXISTS player_stats | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
RESTRICT | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ CREATE TABLE IF NOT EXISTS vips ( | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
RESTRICT | ||
NO ACTION | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,5 @@ CREATE TABLE IF NOT EXISTS player_weapons | |
ON DELETE | ||
CASCADE | ||
ON UPDATE | ||
RESTRICT | ||
NO ACTION | ||
); |