Guest User

Untitled

a guest
Apr 11th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.04 KB | None | 0 0
  1. public OnPlayerDisconnect(playerid, reason){
  2.     new Query[200], name[MAX_PLAYER_NAME];
  3.     GetPlayerName(playerid, name, sizeof(name));
  4.     if(Player[playerid][Mode] == 1){
  5.         GetPlayerPos(playerid, Player[playerid][X], Player[playerid][Y], Player[playerid][Z]);
  6.         GetPlayerHealth(playerid, Player[playerid][Health]);
  7.         GetPlayerArmour(playerid, Player[playerid][Armour]);
  8.         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",
  9.         Player[playerid][Team],
  10.         Player[playerid][Skin],
  11.         GetPlayerMoney(playerid),//
  12.         GetPlayerScore(playerid),//
  13.         Player[playerid][Health],// AND THEN THIS
  14.         Player[playerid][Armour],// THIS TOO
  15.         Player[playerid][X],//
  16.         Player[playerid][Y],//
  17.         Player[playerid][Z],//
  18.         DB_Escape(name));
  19.         db_query(Database, Query);
  20.         Player[playerid][Mode] = 0;}
  21.  
  22.  
  23. public OnPlayerRequestSpawn(playerid){
  24.     if(Player[playerid][Mode] == 1){
  25.         if(Player[playerid][Skin] != 0){
  26.             SetPlayerTeam(playerid, Player[playerid][Team]);
  27.             SetPlayerSkin(playerid, Player[playerid][Skin]);
  28.             GivePlayerMoney(playerid, Player[playerid][Money]);
  29.             SetPlayerScore(playerid, Player[playerid][Score]);
  30.             SetPlayerHealth(playerid, Player[playerid][Health]);
  31.             SetPlayerArmour(playerid, Player[playerid][Armour]);
  32.             SetPlayerPos(playerid, Player[playerid][X], Player[playerid][Y], Player[playerid][Z]);
  33.  
  34. format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
  35.             Result = db_query(Database, Query);
  36.             if(db_num_rows(Result)){
  37.                 new Field[ 20 ]; //Creating a field to retrieve the data
  38.                 db_get_field_assoc(Result, "TEAM", Field, 30);
  39.                 Player[playerid][Team] = strval(Field);
  40.                 db_get_field_assoc(Result, "SKIN", Field, 30);
  41.                 Player[playerid][Skin] = strval(Field);
  42.                 db_get_field_assoc(Result, "MONEY", Field, 30);
  43.                 Player[playerid][Money] = strval(Field);
  44.                 db_get_field_assoc(Result, "SCORE", Field, 30);
  45.                 Player[playerid][Score] = strval(Field);
  46.                 db_get_field_assoc_float(Result, "HEALTH");
  47.                 Player[playerid][Health] = floatstr(Field);
  48.                 db_get_field_assoc_float(Result, "ARMOUR");
  49.                 Player[playerid][Armour] = floatstr(Field);
  50.                 db_get_field_assoc_float(Result, "X");
  51.                 Player[playerid][X] = floatstr(Field);
  52.                 db_get_field_assoc_float(Result, "Y");
  53.                 Player[playerid][Y] = floatstr(Field);
  54.                 db_get_field_assoc_float(Result, "Z");
  55.                 Player[playerid][Z] = floatstr(Field);
  56.  
  57. else{
  58.                 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