Advertisement
Guest User

SDIM

a guest
Mar 18th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.33 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. ////////////////////////////////////////////////////////////////////////////////
  16. main( ) { }
  17. #include <a_samp>
  18. #include <streamer>
  19. #include <YSI\y_ini>
  20. #include <mysql>
  21. //******************************************************************************
  22. // Define-uri
  23. //******************************************************************************
  24. //Colors
  25. #define COLOR_WHITE 0xFFFFFFFF
  26. //
  27. #define SPD ShowPlayerDialog
  28. #define SCM SendClientMessage
  29. #define DIALOG_REGISTER ( 1 )
  30. #define DIALOG_LOGIN ( 2 )
  31. #define DIALOG_SEX ( 3 )
  32. #define DIALOG_VARSTA ( 4 )
  33. #define DIALOG_EMAIL ( 5 )
  34. #define DIALOG_SPAWN ( 6 )
  35. //******************************************************************************
  36. #define mysql_host "localhost"
  37. #define mysql_user "trinity"
  38. #define mysql_db "Accounts"
  39. #define mysql_pass "calculator"
  40. //******************************************************************************
  41. // Forwards
  42. //******************************************************************************
  43. forward RefreshMenuHeader(playerid,Menu:menu,text[]);
  44. //******************************************************************************
  45. // Enums
  46. //******************************************************************************
  47.  
  48. enum PlayerData
  49. {
  50. Nume [ MAX_PLAYER_NAME ] ,
  51. Bani ,
  52. Scor ,
  53. Ucideri ,
  54. Email ,
  55. Sex ,
  56. Varsta ,
  57. Interior ,
  58. Spawn ,
  59. Decese
  60. } ;
  61. new PlayerInfo[MAX_PLAYERS][PlayerData];
  62.  
  63. new
  64. P_DATA [ MAX_PLAYERS ] [ PlayerData ] ,
  65. bool: Logat [ MAX_PLAYERS ] ,
  66. DB:Accounts
  67. ;
  68.  
  69. //******************************************************************************
  70. // Functii Public
  71. //******************************************************************************
  72.  
  73. public OnPlayerCommandText(playerid, cmdtext[])
  74. {
  75. return 0;
  76. }
  77. public OnGameModeInit()
  78. {
  79. print(" ");
  80. print("------[HardCore-Gaming RPG]-------------");
  81. print("________________________________________");
  82. print("---(GameMode creeat de: Trinity)----------");
  83. print(" ");
  84. mysql_connect ( "localhost", "trinity", "Accounts", "calculator" );
  85. SetGameModeText("HC:RP v0.0.1");
  86. AddPlayerClass(60,1743.0549,-1861.2273,13.5778,46.8583,0,0,0,0,0,0);
  87. new
  88. string [ 756 ]
  89. ;
  90. Accounts = db_open ( "Accounts.db" ) ;
  91. strcat ( string , "CREATE TABLE IF NOT EXISTS `Jucatori`" , 756 ) ;
  92. strcat ( string , "(`ID` INTEGER PRIMARY KEY AUTOINCREMENT ,\
  93. `Nume` TEXT ,\
  94. `Parola` TEXT ,\
  95. `Bani` NUMERIC ,\
  96. `Scor` NUMERIC , " , 756 ) ;
  97. strcat ( string , "`Ucideri` NUMERIC ,\
  98. `Decese` NUMERIC ,\
  99. `Email` TEXT ,\
  100. `Sex` NUMERIC ,\
  101. `Varsta` NUMERIC ,\
  102. `Interior` NUMERIC ,\
  103. `Spawn` NUMERIC ) " , 756 ) ;
  104. db_free_result ( db_query ( Accounts , string ) ) ;
  105. return ( 1 ) ;
  106. }
  107. public OnPlayerSpawn(playerid)
  108. {
  109. if(PlayerInfo[playerid][Spawn] == 1)//LS
  110. {
  111. SetPlayerPos(playerid,1743.054931,-1861.227294,13.577773);
  112. SetPlayerFacingAngle(playerid, 0);
  113. SetPlayerInterior(playerid,0);
  114. PlayerInfo[playerid][Interior] = 0;
  115. }
  116. else if(PlayerInfo[playerid][Spawn] == 2)//SF
  117. {
  118. SetPlayerPos(playerid,-1983.503540,137.988937,27.687500);
  119. SetPlayerFacingAngle(playerid, 90);
  120. SetPlayerInterior(playerid,0);
  121. PlayerInfo[playerid][Interior] = 0;
  122. }
  123. else if(PlayerInfo[playerid][Spawn] == 3)//LV
  124. {
  125. SetPlayerPos(playerid,1932.8171,1345.1152,9.9688);
  126. SetPlayerFacingAngle(playerid, -90);
  127. SetPlayerInterior(playerid,0);
  128. PlayerInfo[playerid][Interior] = 0;
  129. }
  130.  
  131. }
  132. public OnGameModeExit()
  133. {
  134. db_close ( Accounts ) ;
  135. return ( 1 ) ;
  136. }
  137. public OnPlayerConnect ( playerid )
  138. {
  139. new
  140. Query [ 256 ] ,
  141. pNume [ MAX_PLAYER_NAME ] ,
  142. DBResult:Result
  143. ;
  144. Logat [ playerid ] = false ;
  145. GetPlayerName ( playerid , pNume , MAX_PLAYER_NAME ) ;
  146. strcpy ( P_DATA [ playerid ] [ Nume ] , DB_Escape ( pNume ) , MAX_PLAYER_NAME ) ;
  147. format ( Query , 256 , "SELECT * FROM `Jucatori` WHERE `Nume` = '%s'" , P_DATA [ playerid ] [ Nume ] ) ;
  148. Result = db_query ( Accounts , Query ) ;
  149. if ( db_num_rows ( Result ) > 0 )
  150. SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  151. else
  152. ShowPlayerDialog(playerid,DIALOG_EMAIL,DIALOG_STYLE_INPUT,"Email","Scrie aici email-ul tau","O.K.","");
  153. db_free_result ( Result ) ;
  154. return ( 1 ) ;
  155. }
  156. public OnPlayerDisconnect ( playerid , reason )
  157. {
  158. if ( Logat [ playerid ] )
  159. {
  160. new
  161. Query [ 256 ]
  162. ;
  163. format ( Query , sizeof ( Query ) , "UPDATE `Jucatori` SET `Bani` = '%d' ,`Scor` = '%d' , `Ucideri` = '%d' , `Decese` = '%d' , `Sex` = '%d' , `Interior` = '%d' , `Varsta` = '%d' , 'Spawn' ='%d' WHERE `Nume` = '%s'"
  164. , GetPlayerMoney ( playerid ) , GetPlayerScore ( playerid ) , P_DATA [ playerid ] [ Ucideri ] , P_DATA [ playerid ] [ Decese ] , P_DATA [ playerid ] [ Nume ] ) ;
  165. db_free_result ( db_query ( Accounts , Query ) ) ;
  166. }
  167. return ( 1 ) ;
  168. }
  169. public OnPlayerDeath ( playerid , killerid , reason )
  170. {
  171. P_DATA [ playerid ] [ Decese ] ++ ;
  172. if ( killerid != INVALID_PLAYER_ID )
  173. {
  174. P_DATA [ killerid ] [ Ucideri ] ++ ;
  175. }
  176. return ( 1 ) ;
  177. }
  178. public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [ ] )
  179. {
  180. if ( dialogid == DIALOG_EMAIL )
  181. {
  182. if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_EMAIL,DIALOG_STYLE_INPUT,"Email","Scrie aici email-ul tau","O.K.","");
  183. new email = strval(inputtext);
  184. new
  185. Query [ 256 ]
  186. ;
  187. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Email` ) VALUE ( '%s' )"
  188. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , email ) ;
  189. db_free_result ( db_query ( Accounts , Query ) ) ;
  190. SPD ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , "Inregistreaza-te" , "Introduceti o parola pentru a va inregistra:" , "Register" , "" );
  191. return ( 1 ) ;
  192. }
  193. if ( dialogid == DIALOG_REGISTER )
  194. {
  195. if ( !response || isnull(inputtext ) ) return SPD ( playerid , DIALOG_REGISTER , DIALOG_STYLE_PASSWORD , "Inregistreaza-te" , "Introduceti o parola pentru a va inregistra:" , "Register" , "" ) ;
  196. new
  197. Query [ 256 ]
  198. ;
  199. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Nume` , `Parola` , `Bani` , `Scor` , `Ucideri` , `Decese` ) VALUES ( '%s' , '%s', '%d' , '%d' , '%d' , '%d' )"
  200. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , 500 , 0 , 0 , 0 ) ;
  201. db_free_result ( db_query ( Accounts , Query ) ) ;
  202. ShowPlayerDialog(playerid,DIALOG_SEX,DIALOG_STYLE_LIST,"Care este sexul tau?","Masculin \nFeminin","Select","");
  203. return ( 1 ) ;
  204. }
  205. if(dialogid == DIALOG_SEX)
  206. {
  207. if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_SEX,DIALOG_STYLE_LIST,"Care este sexul tau?","Masculin \nFeminin","Select","");
  208. {
  209. if(listitem == 0)
  210. {
  211. PlayerInfo[playerid][Sex] = 1;
  212. new
  213. Query [ 256 ]
  214. ;
  215. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Sex` ) VALUE ( '%d' )"
  216. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Sex] ) ;
  217. db_free_result ( db_query ( Accounts , Query ) ) ;
  218. SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,Deci esti baiat");
  219. ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
  220. }
  221. else if(listitem == 1)
  222. {
  223. PlayerInfo[playerid][Sex] = 1;
  224. new
  225. Query [ 256 ]
  226. ;
  227. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Sex` ) VALUE ( '%d' )"
  228. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Sex] ) ;
  229. db_free_result ( db_query ( Accounts , Query ) ) ;
  230. SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,Deci esti fata");
  231. ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
  232. }
  233. }
  234. }
  235. if(dialogid == DIALOG_VARSTA)
  236. {
  237. if ( !response || isnull(inputtext ) ) return ShowPlayerDialog(playerid,DIALOG_VARSTA,DIALOG_STYLE_INPUT,"Varsta","Scrie ce varsta ai!","OK","");
  238. {
  239. new varsta = strval(inputtext);
  240. if(varsta >5 && varsta<90)
  241. {
  242. new
  243. Query [ 256 ]
  244. ;
  245. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Varsta` ) VALUE ( '%d' )"
  246. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , varsta ) ;
  247. db_free_result ( db_query ( Accounts , Query ) ) ;
  248. new string[256];
  249. format(string,256,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci ai %d ani",varsta);
  250. SendClientMessage(playerid,COLOR_WHITE,string);
  251. }
  252. }
  253. SCM ( playerid , -1 , "Te-ai inregistrat cu succes." ) ;
  254. ShowPlayerDialog(playerid,DIALOG_SPAWN,DIALOG_STYLE_LIST,"Alege unde vrei sa fi spawnat","Los Santos \nSan Fierro \nLas Venturas","Select","");
  255. // SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "Renunta" ) ;
  256. }
  257. if(dialogid == DIALOG_SPAWN)
  258. {
  259. if(response)
  260. {
  261. if(listitem == 0)
  262. {
  263. PlayerInfo[playerid][Spawn] = 1;//LS
  264. new
  265. Query [ 256 ]
  266. ;
  267. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
  268. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
  269. db_free_result ( db_query ( Accounts , Query ) ) ;
  270. SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in Los Santos");
  271. SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  272. }
  273. else if(listitem == 1)
  274. {
  275. PlayerInfo[playerid][Spawn] = 2;//SF
  276. new
  277. Query [ 256 ]
  278. ;
  279. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
  280. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
  281. db_free_result ( db_query ( Accounts , Query ) ) ;
  282. SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in San Fierro");
  283. SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  284. }
  285. else if(listitem == 2)
  286. {
  287. new
  288. Query [ 256 ]
  289. ;
  290. format ( Query , sizeof ( Query ) , "INSERT INTO `Jucatori` ( `Spawn` ) VALUE ( '%d' )"
  291. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) , PlayerInfo[playerid][Spawn] ) ;
  292. db_free_result ( db_query ( Accounts , Query ) ) ;
  293. PlayerInfo[playerid][Spawn] = 3;//LV
  294. SendClientMessage(playerid,COLOR_WHITE,"[{3399FF}HardCore-Gaming{FFFFFF}]Bine,deci vei fi spawnat in Las Venturas");
  295. SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  296. }
  297. }
  298. }
  299. if ( dialogid == DIALOG_LOGIN )
  300. {
  301. if ( !response || isnull ( inputtext ) ) return SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  302. new
  303. Query [ 256 ] ,
  304. DBResult:Result
  305. ;
  306. format ( Query , sizeof ( Query ) , "SELECT `Bani` , `Scor` , `Ucideri` , `Decese` , 'Email' , 'Sex' , 'Varsta' , 'Interior' FROM `Jucatori` WHERE `Nume` = '%s' AND `Parola` = '%s'"
  307. , P_DATA [ playerid ] [ Nume ] , DB_Escape ( inputtext ) ) ;
  308. Result = db_query ( Accounts , Query ) ;
  309. if ( db_num_rows ( Result ) )
  310. {
  311. new
  312. Field [ 30 ]
  313. ;
  314. db_get_field_assoc ( Result , "Bani" , Field , 30 ) ;
  315. P_DATA [ playerid ] [ Bani ] = strval ( Field ) ;
  316. ResetPlayerMoney ( playerid ) ;
  317. GivePlayerMoney ( playerid , strval ( Field ) ) ;
  318.  
  319. db_get_field_assoc ( Result , "Scor" , Field , 30 ) ;
  320. P_DATA [ playerid ] [ Scor ] = strval ( Field ) ;
  321. SetPlayerScore ( playerid , strval ( Field ) ) ;
  322.  
  323. db_get_field_assoc ( Result , "Ucideri" , Field , 30 ) ;
  324. P_DATA [ playerid ] [ Ucideri ] = strval ( Field ) ;
  325.  
  326. db_get_field_assoc ( Result , "Decese" , Field , 30 ) ;
  327. P_DATA [ playerid ] [ Decese ] = strval(Field);
  328.  
  329. db_get_field_assoc ( Result , "Email" , Field , 30 ) ;
  330. P_DATA [ playerid ] [ Interior ] = strval(Field);
  331.  
  332. db_get_field_assoc ( Result , "Sex" , Field , 30 ) ;
  333. P_DATA [ playerid ] [ Sex ] = strval(Field);
  334.  
  335. db_get_field_assoc ( Result , "Varsta" , Field , 30 ) ;
  336. P_DATA [ playerid ] [ Varsta ] = strval(Field);
  337.  
  338. db_get_field_assoc ( Result , "Interior" , Field , 30 ) ;
  339. P_DATA [ playerid ] [ Interior ] = strval(Field);
  340.  
  341. }
  342. else
  343. {
  344. SPD ( playerid , DIALOG_LOGIN , DIALOG_STYLE_PASSWORD , "Logheaza-te" , "Parola gresita.Introdu parola in casuta de mai jos:" , "Login" , "" ) ;
  345. }
  346. db_free_result ( Result ) ;
  347. Logat [ playerid ] = true ;
  348. SpawnPlayer(playerid);
  349. return ( 1 ) ;
  350. }
  351. return ( 0 ) ;
  352. }
  353. stock DB_Escape ( text [] )
  354. {
  355. new
  356. ret[ MAX_INI_ENTRY_TEXT * 2 ] ,
  357. ch ,
  358. i ,
  359. j
  360. ;
  361. while ( ( ch = text [ i++ ] ) && j < sizeof ( ret ) )
  362. {
  363. if ( ch == '\'' )
  364. {
  365. if ( j < sizeof ( ret ) - 2 )
  366. {
  367. ret [ j++ ] = '\'' ;
  368. ret [ j++ ] = '\'' ;
  369. }
  370. }
  371. else if ( j < sizeof ( ret ) )
  372. {
  373. ret [ j++ ] = ch ;
  374. }
  375. else
  376. {
  377. j++ ;
  378. }
  379. }
  380. ret [ sizeof ( ret ) - 1 ] = '\0' ;
  381. return ret ;
  382. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement