20.06.2018, 02:39
Good idea, but personally I think that the g2o packages are enough and do not require any improvements, look at the fragment of my code and see that it's enough (I do not want you to treat it as hatred)
Squirrel Script
- enum packetList
- {
- option_lineChat,
- option_hud,
- option_password,
- option_notifications,
-
- id = 255
- };
-
- class PlayerOptions
- {
- constructor(server){
- SCore = server;
- SPlayer = server.SPlayer;
- }
-
- function changeLine(pid, lines)
- {
- mysql_query(SCore.handler, "UPDATE options SET `chat_lines` = '"+lines+"' WHERE `login` = '"+SPlayer[pid].login+"'");
- }
-
- function changeHud(pid, layout)
- {
- mysql_query(SCore.handler, "UPDATE options SET `hud_layout` = '"+layout+"' WHERE `login` = '"+SPlayer[pid].login+"'");
- }
-
- function changePassword(pid, oldPass, newPass)
- {
- local result = mysql_query(SCore.handler, "SELECT * FROM players WHERE `login` = '"+SPlayer[pid].login+"' AND password = '"+crypt(oldPass)+"'");
- if(result)
- {
- local row = mysql_fetch_assoc(result);
- if(row)
- {
- mysql_query(SCore.handler, "UPDATE players SET `password` = '"+newPass+"' WHERE `login` = '"+SPlayer[pid].login+"'");
- }
- mysql_free_result(result);
- }
- }
-
- function changeNotifications(pid, notification)
- {
- mysql_query(SCore.handler, "UPDATE options SET `notification` = '"+notification+"' WHERE `login` = '"+SPlayer[pid].login+"'");
- }
-
- function receivedPacket(pid, packet)
- {
- if(packet.readUInt8() == packetList.id)
- {
- switch(packet.readUInt8())
- {
- case packetList.option_lineChat: changeLine(pid, packet.readInt8()); break;
- case packetList.option_hud: changeHud(pid, packet.readInt8()); break;
- case packetList.option_password: changePassword(pid, packet.readString(), packet.readString()); break;
- case packetList.option_notifications: changeNotifications(pid, packet.readBool()); break;
- }
- }
- }
-
- SCore = null;
- SPlayer = null;
- }