Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnPlayerDisconnect(playerid, reason){
- new Query[200], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- if(Player[playerid][Mode] == 1){
- GetPlayerPos(playerid, Player[playerid][X], Player[playerid][Y], Player[playerid][Z]);
- GetPlayerHealth(playerid, Player[playerid][Health]);
- GetPlayerArmour(playerid, Player[playerid][Armour]);
- format(Query,sizeof(Query),"UPDATE `USERS` SET TEAM = '%d', SKIN = '%d', MONEY = '%d', SCORE = '%d', HEALTH = '%f', ARMOUR = '%f', X = '%f', Y = '%f', Z = '%f' WHERE `NAME` = '%s' COLLATE NOCASE",
- Player[playerid][Team],
- Player[playerid][Skin],
- GetPlayerMoney(playerid),//
- GetPlayerScore(playerid),//
- Player[playerid][Health],// AND THEN THIS
- Player[playerid][Armour],// THIS TOO
- Player[playerid][X],//
- Player[playerid][Y],//
- Player[playerid][Z],//
- DB_Escape(name));
- db_query(Database, Query);
- Player[playerid][Mode] = 0;}
- public OnPlayerRequestSpawn(playerid){
- if(Player[playerid][Mode] == 1){
- if(Player[playerid][Skin] != 0){
- SetPlayerTeam(playerid, Player[playerid][Team]);
- SetPlayerSkin(playerid, Player[playerid][Skin]);
- GivePlayerMoney(playerid, Player[playerid][Money]);
- SetPlayerScore(playerid, Player[playerid][Score]);
- SetPlayerHealth(playerid, Player[playerid][Health]);
- SetPlayerArmour(playerid, Player[playerid][Armour]);
- SetPlayerPos(playerid, Player[playerid][X], Player[playerid][Y], Player[playerid][Z]);
- format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
- Result = db_query(Database, Query);
- if(db_num_rows(Result)){
- new Field[ 20 ]; //Creating a field to retrieve the data
- db_get_field_assoc(Result, "TEAM", Field, 30);
- Player[playerid][Team] = strval(Field);
- db_get_field_assoc(Result, "SKIN", Field, 30);
- Player[playerid][Skin] = strval(Field);
- db_get_field_assoc(Result, "MONEY", Field, 30);
- Player[playerid][Money] = strval(Field);
- db_get_field_assoc(Result, "SCORE", Field, 30);
- Player[playerid][Score] = strval(Field);
- db_get_field_assoc_float(Result, "HEALTH");
- Player[playerid][Health] = floatstr(Field);
- db_get_field_assoc_float(Result, "ARMOUR");
- Player[playerid][Armour] = floatstr(Field);
- db_get_field_assoc_float(Result, "X");
- Player[playerid][X] = floatstr(Field);
- db_get_field_assoc_float(Result, "Y");
- Player[playerid][Y] = floatstr(Field);
- db_get_field_assoc_float(Result, "Z");
- Player[playerid][Z] = floatstr(Field);
- else{
- format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `TEAM`, `SKIN`, `MONEY`, `SCORE`, `HEALTH`, `ARMOUR`, `X`, `Y`, `Z`) VALUES('%s','%s','%s', '0', '0', '0', '0', '%f', '%f', '%f', '%f', '%f')", DB_Escape(name), DB_Escape(inputtext), DB_Escape(ip));// Inserting all these items into the database, confirming it's register was successful.
Advertisement
Add Comment
Please, Sign In to add comment