Guest User

Untitled

a guest
Jan 4th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.89 KB | None | 0 0
  1.  
  2.  
  3. //------------------------------------------------------------------[ Includes ]
  4. #include <a_samp>
  5. #include <a_mysql>
  6. #include <time>
  7. #include <file> // système de log par exemple
  8. #include <sscanf2>
  9. //-------------------------------------------------------------[Connexion ]
  10. #define mysql_host "127.0.0.1" //Has to be a string
  11. #define mysql_user "root" //Has to be a string
  12. #define mysql_password "an1106" //There is none for wamp unless you set one.
  13. #define mysql_database "LSI-RP" //Has to be a string
  14. //-------------------------------------------------------------[ Server Limits ]
  15. #define JoueursMax  GetMaxPlayers()
  16. #define MaxVoiture MAX_VEHICLES
  17. #define MaxObjets  MAX_OBJECTS
  18. //--------------------------------------------------------------------[ Colors ]
  19. #define Noir   "{000000}"
  20. #define Blanc   "{FFFFFF}"
  21. #define Gris   "{BFBFBF}"
  22. #define Rouge    "{FF0000}"
  23. #define Orange  "{FFA500}"
  24. #define Jaune  "{FFFF00}"
  25. #define Vert   "{008000}"
  26. #define Bleu    "{0000FF}"
  27. #define Violet  "{800080}"
  28. #define Teal    "{008080}"
  29. //--------------------------------------------------------------[ Milliseconds ]
  30. #define An    31536000000 // Day x 365
  31. #define Mois   2592000000  // Day x 30
  32. #define Semaine    604800000   // Day x 7
  33. #define Jour     86400000    // Hour x 24
  34. #define Heure    3600000     // Minute x 60
  35. #define Minute  60000       // Second x 60
  36. #define Seconde  1000        // Millisecond x 1000
  37. //-----------------------------------------------------------------[ Variables ]
  38. //--------------------------------------------------------------------[ Unused ]
  39. main() {}
  40. //--------------------------------------------------------------------[ Timers ]
  41. //----------------------------------------------------------[ Custom Functions ]
  42. //---------------------------------------------------------[ Default Callbacks ]
  43. public OnGameModeInit() {
  44.     mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password);
  45.     enum PlayerInfo
  46.     {
  47.     Username[23],
  48.     Password[24],
  49.     Argent
  50.     }
  51.     new PInfo[MAX_PLAYERS][PlayerInfo];
  52.     return true;
  53. }
  54.  
  55. public OnGameModeExit() {
  56.     return true;
  57. }
  58.  
  59. public OnPlayerConnect(playerid) {
  60.     new Query[80],pName[24],string[164];
  61.     GetPlayerName(playerid,pName,24);
  62.     format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
  63.     mysql_query(Query);
  64.     mysql_store_result();
  65.     if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
  66.         {
  67.         format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
  68.         ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Lo g in",string,"Login","");
  69.         }
  70.     else
  71.         {
  72.         format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
  73.         ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Re gister",string,"Register","");
  74.         }
  75.     mysql_free_result();
  76.     return true;
  77. }
  78.  
  79. public OnPlayerDisconnect(playerid, reason) {
  80.     return true;
  81. }
  82.  
  83. public OnPlayerRequestClass(playerid, classid) {
  84.     return true;
  85. }
  86.  
  87. public OnPlayerRequestSpawn(playerid) {
  88.     return true;
  89. }
  90.  
  91. public OnPlayerSpawn(playerid) {
  92.     return true;
  93. }
  94.  
  95. public OnPlayerDeath(playerid, killerid, reason) {
  96.     return true;
  97. }
  98.  
  99. public OnVehicleSpawn(vehicleid) {
  100.     return true;
  101. }
  102.  
  103. public OnVehicleDeath(vehicleid, killerid) {
  104.     return true;
  105. }
  106.  
  107. public OnPlayerText(playerid, text[]) {
  108.     return true;
  109. }
  110.  
  111. public OnPlayerCommandText(playerid, cmdtext[]) {
  112.     OnPlayerText(playerid, cmdtext);
  113.     return true;
  114. }
  115.  
  116. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
  117.     return true;
  118. }
  119.  
  120. public OnPlayerExitVehicle(playerid, vehicleid) {
  121.     return true;
  122. }
  123.  
  124. public OnPlayerStateChange(playerid, newstate, oldstate) {
  125.     return true;
  126. }
  127.  
  128. public OnPlayerEnterCheckpoint(playerid) {
  129.     return true;
  130. }
  131.  
  132. public OnPlayerLeaveCheckpoint(playerid) {
  133.     return true;
  134. }
  135.  
  136. public OnPlayerEnterRaceCheckpoint(playerid) {
  137.     return true;
  138. }
  139.  
  140. public OnPlayerLeaveRaceCheckpoint(playerid) {
  141.     return true;
  142. }
  143.  
  144. public OnRconCommand(cmd[]) {
  145.     return true;
  146. }
  147.  
  148. public OnObjectMoved(objectid) {
  149.     return true;
  150. }
  151.  
  152. public OnPlayerObjectMoved(playerid, objectid) {
  153.     return true;
  154. }
  155.  
  156. public OnPlayerPickUpPickup(playerid, pickupid) {
  157.     return true;
  158. }
  159.  
  160. public OnVehicleMod(playerid, vehicleid, componentid) {
  161.     return true;
  162. }
  163.  
  164. public OnEnterExitModShop(playerid, enterexit, interiorid) {
  165.     return true;
  166. }
  167.  
  168. public OnVehiclePaintjob(playerid, vehicleid, paintjobid) {
  169.     return true;
  170. }
  171.  
  172. public OnVehicleRespray(playerid, vehicleid, color1, color2) {
  173.     return true;
  174. }
  175.  
  176. public OnVehicleDamageStatusUpdate(vehicleid, playerid) {
  177.     return true;
  178. }
  179.  
  180. public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat) {
  181.     return true;
  182. }
  183.  
  184. public OnPlayerSelectedMenuRow(playerid, row) {
  185.     return true;
  186. }
  187.  
  188. public OnPlayerExitedMenu(playerid) {
  189.     return true;
  190. }
  191.  
  192. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) {
  193.     return true;
  194. }
  195.  
  196. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  197.     return true;
  198. }
  199.  
  200. public OnRconLoginAttempt(ip[], password[], success ) {
  201.     return true;
  202. }
  203.  
  204. public OnPlayerUpdate(playerid) {
  205.     return true;
  206. }
  207.  
  208. public OnPlayerStreamIn(playerid, forplayerid) {
  209.     return true;
  210. }
  211.  
  212. public OnPlayerStreamOut(playerid, forplayerid) {
  213.     return true;
  214. }
  215.  
  216. public OnVehicleStreamIn(vehicleid, forplayerid) {
  217.     return true;
  218. }
  219.  
  220. public OnVehicleStreamOut(vehicleid, forplayerid) {
  221.     return true;
  222. }
  223.  
  224. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  225.  
  226. if(dialogid == Logindialog)
  227. {
  228. if(strlen(inputtext) == 0)
  229. {
  230. ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_I NPUT,"Register - Entrez votre mdp","You are about to register a new account! \nChoississez un mdp \n","Register!","");
  231. }
  232. else
  233. {
  234. LoginPlayer(playerid,inputtext);
  235. }
  236. }
  237.     return true;
  238. }
  239.  
  240. public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid) {
  241.     return true;
  242. }
  243.  
  244. public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid) {
  245.     return true;
  246. }
  247.  
  248. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ) {
  249.     return true;
  250. }
  251.  
  252. public OnPlayerClickTextDraw(playerid, Text:clickedid) {
  253.     return true;
  254. }
  255.  
  256. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) {
  257.     return true;
  258. }
  259.  
  260. public OnPlayerClickPlayer(playerid, clickedplayerid, source) {
  261.     return true;
  262. }
  263.  
  264. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ ) {
  265.     return true;
  266. }
  267.  
  268. public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ ) {
  269.     return true;
  270. }
  271.  
  272. public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ) {
  273.     return true;
  274. }
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281. stock LoginPlayer(playerid,const password[])
  282. {
  283. new EscapedText[60];
  284. mysql_real_escape_string(password, EscapedText);
  285. format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",GetPName(playerid),EscapedText);
  286. mysql_query(Query);
  287. mysql_store_result();
  288. if(mysql_num_rows() != 0)
  289. {
  290. SendClientMessage(playerid,green,"You have been logged in!");
  291. LoadStats(playerid);
  292. }
  293. else
  294. {
  295. SendClientMessage(playerid,red,"Wrong password!");
  296. Kick(playerid);
  297. }
  298. mysql_free_result();
  299. return 1;
  300. }
  301.  
  302.  
  303.  
  304.  
  305. stock LoadStats(playerid)
  306. {
  307. new pName[24],Query[80];
  308. GetPlayerName(playerid,pName,24);
  309. format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ", pName);
  310. mysql_query(Query);
  311. mysql_store_result();
  312. mysql_fetch_row_format(Query, "|");
  313. sscanf(Query, "e<p<|>s[24]s[23]i>", PInfo[playerid]);
  314. mysql_free_result();
  315. GivePlayerMoney(playerid,PInfo[playerid][Money]);
  316. return 1;
  317. }
Advertisement
Add Comment
Please, Sign In to add comment