20.05.2011, 21:18
Script I use: My GameMode of 0
A detailed description of the problem: I have a command / and register / login, but I do not know how to do to register and login is no longer in controls than that in the dialog, I know what to do showplayerdialog as soon as the player connects but how to make it what goes under OnDialogResponse.
Part of the script:
A detailed description of the problem: I have a command / and register / login, but I do not know how to do to register and login is no longer in controls than that in the dialog, I know what to do showplayerdialog as soon as the player connects but how to make it what goes under OnDialogResponse.
Part of the script:
Код:
CMD: register (playerid, params []) { if (GetPVarInt (playerid, "Logged")) return SendClientMessage (playerid, COLOR_ORANGE, "[*] You're already logged in!"); if (isnull (params)) return SendClientMessage (playerid, COLOR_ORANGE, "[*] Usage: / register [pass]"); New query [320], pName [MAX_PLAYER_NAME]; GetPlayerName (playerid, pName, MAX_PLAYER_NAME); mysql_real_escape_string (pName, pName); format (Query, sizeof Query "SELECT * FROM` Accounts `WHERE` Name `= '% s' LIMIT 1", pName); mysql_query (Query); mysql_store_result (); if (mysql_num_rows ()) { SendClientMessage (playerid, COLOR_ORANGE, "[*] An account already exists under that name! Use \" / login \ "to log in!"); mysql_free_result (); return 1; } mysql_free_result (); WP_Hash (Query, 129, params); New IP [16]; GetPlayerIp (playerid, IP, 16); format (Query, sizeof Query "INSERT INTO` accounts `(Name, Password, IP, Admin, Money, Score, Kills, Deaths) VALUES ('% s', '% s', '% s'% i, % i,% i,% i,% i) " pName, Query, IP, GetPVarInt (playerid, "Admin") GetPlayerMoney (playerid) GetPlayerScore (playerid) GetPVarInt (playerid, "Kills") GetPVarInt (playerid, "Deaths")); mysql_query (Query); SetPVarInt (playerid, "Logged", 1); SendClientMessage (playerid, COLOR_LIMEGREEN, "[*] SUCCESSFULLY registered and automatically logged in!"); return 1; }
Код:
CMD: login (playerid, params []) { if (GetPVarInt (playerid, "Logged")) return SendClientMessage (playerid, COLOR_ORANGE, "[*] You're already logged in!"); if (isnull (params)) return SendClientMessage (playerid, COLOR_ORANGE, "[*] Usage: / login [pass]"); New query [256], pName [MAX_PLAYER_NAME]; GetPlayerName (playerid, pName, MAX_PLAYER_NAME); mysql_real_escape_string (pName, pName); format (Query, sizeof Query "SELECT * FROM` Accounts `WHERE` Name `= '% s' LIMIT 1", pName); mysql_query (Query); mysql_store_result (); if (mysql_num_rows ()) { SendClientMessage (playerid, COLOR_ORANGE, "[*] You're not registered! Use \" register \ "to register an account!"); mysql_free_result (); return 1; } mysql_free_result (); WP_Hash (Query, 129, params); format (Query, sizeof Query "SELECT * FROM` Accounts `WHERE` Name `= '% s' AND` Password `= '% s' LIMIT 1", pName, Query); mysql_query (Query); mysql_store_result (); if (mysql_num_rows ()) { SetPVarInt (playerid, "LoginWarns" GetPVarInt (playerid, "LoginWarns") + 1); if (GetPVarInt (playerid, "LoginWarns") == 3) { format (Query, sizeof Query, "[*]% s has been kicked for 3 wrong login attempts", pName); SendClientMessageToAll (COLOR_ROYALBLUE, Query); Kick (playerid); } else { format (Query, sizeof Query, "[*] Wrong password! Attempt% and out of third, GetPVarInt (playerid," LoginWarns ")); SendClientMessage (playerid, COLOR_ORANGE, Query); } return 1; } mysql_num_rows (Query); new values [5]; sscanf (Query, "p <|> {s [24] with the [129] to [16]} and <i> [5], values); / / Enjoy editing. SetPVarInt (playerid, "Admin", values [0]); GivePlayerMoney (playerid, values [1]); SetPlayerScore (playerid, values [2]); SetPVarInt (playerid, "Kills", values [3]); SetPVarInt (playerid, "Deaths", values [4]); mysql_free_result (); SetPVarInt (playerid, "Logged", 1); SendClientMessage (playerid, COLOR_LIMEGREEN, "[*] SUCCESSFULLY logged in!"); / / IP setting GetPlayerIp (playerid, Query, 16); format (Query, sizeof Query, "UPDATE` Accounts `SET` ip `= '% s' WHERE` Name `= '% s' LIMIT 1", Query, pName); mysql_query (Query); return 1; }