Advertisement
Guest User

FaceBook

a guest
Jan 26th, 2012
5,899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.92 KB | None | 0 0
  1. #include < a_samp >
  2. #include < zcmd >
  3. #include < sscanf2 >
  4.  
  5. #define COLOR_RED 0xFF0000AA
  6. #define GREEN 0x00FF00AA
  7. #define COLOR_GREY 0xAFAFAFAA
  8. #define COLOR_ORANGE 0xFF9900AA
  9.  
  10. #define ONCONN 12200
  11. #define ONLOG 12300
  12. #define MYFB 1000
  13. #define FB 12600
  14. #define MOD 12700
  15. #define AgeSet 12800
  16. #define StatusSet 12900
  17. #define CountrySet 13000
  18. #define SexSet 13100
  19. #define LikesReset 13200
  20. #define ViewsReset 13300
  21. #define OcupationSet 13400
  22. #define PrivacySet 13500
  23. #define DELETE 13600
  24. #define Warning1 13700
  25. #define Warning2 13800
  26. #define OnCreateFaceBook 13900
  27. #define Dialog_LoginFAccount 16000
  28. #define Dialog_LoginFAccount2 17000
  29. #define Dialog_PlayerProfile 18000
  30. #define Dialog_FHelp 19000
  31. #define db_assoc db:get_field_assoc
  32. #define db: db_
  33.  
  34. #define Use_Speed_Text true
  35.  
  36. new const Languages[ ] = { "Romana", "English", "Polsky", "Slovensky", "Intalia", "Spanish", "Portugese", "German", "Swedish", "Bulgaria", "Arab" };
  37.  
  38. enum pInfo
  39. {
  40. Age,
  41. Likes,
  42. Views,
  43. Privacy,
  44. Logged,
  45. };
  46. new P_DATA[ MAX_PLAYERS ][ pInfo ];
  47. new DB:Database;
  48. new pViewing[ MAX_PLAYERS ];
  49. //=============================== [ CallBacks ] ==============================//
  50. public OnFilterScriptInit( )
  51. {
  52. Database = db:open( "FaceBook.db" );
  53. db:query( Database, "CREATE TABLE IF NOT EXISTS `FProfiles` (`Nume` TEXT, \
  54. `Password` TEXT, \
  55. `Age` NUMERIC, \
  56. `Sex` TEXT, \
  57. `Country` TEXT, \
  58. `Likes` NUMERIC, \
  59. `Views` NUMERIC, \
  60. `Privacy` NUMERIC, \
  61. `Status` TEXT, \
  62. `Ocupation` TEXT, \
  63. `Expiration` TEXT)" );
  64. return 1;
  65. }
  66. public OnFilterScriptExit( ) return db:close( Database );
  67. public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
  68. {
  69. if ( dialogid == Dialog_LoginFAccount )
  70. {
  71. new DBResult:R, Query[ 256 ], FPassword[ 128 ], Field[ 128 ];
  72. if ( !response ) return 1;
  73. if ( sscanf( inputtext, "s[128]", FPassword ) ) return ShowPlayerDialog( playerid, Dialog_LoginFAccount, DIALOG_STYLE_INPUT, "Login your facebook account", "You need to type a password!", "Login", "Cancel" );
  74. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  75. R = db:query( Database, Query );
  76. if ( R )
  77. {
  78. if ( db:num_rows( R ) )
  79. {
  80. new DBResult:R2;
  81. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s' AND `Password` = '%s'", PlayerName2( playerid ), FPassword );
  82. R2 = db:query( Database, Query );
  83. if ( db:num_rows( R2 ) )
  84. {
  85. db:get_field_assoc( R, "Age", Field, 128 );
  86. P_DATA[ playerid ][ Age ] = strval( Field );
  87. db:get_field_assoc( R, "Likes", Field, 128 );
  88. P_DATA[ playerid ][ Likes ] = strval( Field );
  89. db:get_field_assoc( R, "Views", Field, 128 );
  90. P_DATA[ playerid ][ Views ] = strval( Field );
  91. db:get_field_assoc( R, "Privacy", Field, 128 );
  92. P_DATA[ playerid ][ Privacy ] = strval( Field );
  93.  
  94. new Str[ 128 ];
  95. strcat( Str, "{00FF00}You have logged succesfully!\n\
  96. {00FF00}If you want to change somethink to your facebook\n\
  97. {00FF00}please click on second dialog button!\n" );
  98. ShowPlayerDialog( playerid, ONLOG, DIALOG_STYLE_MSGBOX, "FaceBook", Str, "MyProfile", "Cancel" );
  99.  
  100. P_DATA[ playerid ][ Logged ] = 1;
  101. }
  102. else return ShowPlayerDialog( playerid, Dialog_LoginFAccount, DIALOG_STYLE_INPUT, "Login your FaceBook account", "{FF0000}An error has encoured!\n{FFFFFF}Invalid password! Please type it again:", "Login", "Cancel" );
  103. db:free_result( R2 );
  104. }
  105. else return ShowPlayerDialog( playerid, Dialog_LoginFAccount2, DIALOG_STYLE_MSGBOX, "Login your FaceBook account", "{FF0000}An error has encoured!\n{FFFFFF}This user don't have an account.\nYou can create a new one by click on button 'Create'.", "Cancel", "Create" );
  106. db:free_result( R );
  107. }
  108. }
  109. if ( dialogid == Dialog_LoginFAccount2 )
  110. {
  111. if ( !response ) return CallRemoteFunction( "OnPlayerCommandText", "is", playerid, "/cfacebook" );
  112. }
  113. if ( dialogid == OnCreateFaceBook+1 )
  114. {
  115. if ( !response ) return 1;
  116. SetPVarInt( playerid, "CreatingProfile", 1 );
  117. ShowPlayerDialog( playerid, StatusSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Insert the new status what do you want to\n{FF0000}appear on your profile:", "Change", "Back" );
  118. return 1;
  119. }
  120. if ( dialogid == ONLOG )
  121. {
  122. if( !response ) return 1;
  123. FormatFBDialog( playerid );
  124. }
  125. if( dialogid == MYFB )
  126. {
  127. if( !response )
  128. {
  129. new str[ 312 ];
  130. strcat( str, "{FFFF00}MODIFY: {FFFFFF}Status\n\
  131. {FFFF00}MODIFY: {FFFFFF}Age\n\
  132. {FFFF00}MODIFY: {FFFFFF}Sex\n\
  133. {FFFF00}MODIFY: {FFFFFF}Country\n\
  134. {FF0000}RESET: {FFFFFF}Likes\n\
  135. {FF0000}RESET: {FFFFFF}Profile Views\n\
  136. {FFFF00}MODIFY: {FFFFFF}Ocupation\n\
  137. {FFFF00}MODIFY: {FFFFFF}Profile Privacy\n\
  138. {FF9900}Exit" );
  139. ShowPlayerDialog( playerid, MOD, DIALOG_STYLE_LIST, "Profile changes", str, "Select", "" );
  140. }
  141. }
  142. if ( dialogid == FB )
  143. {
  144. new Query[ 256 ], string[ 128 ], Time[ 3 ];
  145. if ( !response ) return 1;
  146. if ( P_DATA[ pViewing[ playerid ] ][ Logged ] == 0 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: Player must be logged in his facebook account to can receive likes!" );
  147.  
  148. format( Query, 256, "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  149. new DBResult:R2 = db:query( Database, Query );
  150. gettime( Time[ 0 ], Time[ 1 ] );
  151. getdate( .day = Time[ 2 ] );
  152. if ( R2 )
  153. {
  154. if ( db:free_result( R2 ) )
  155. {
  156. new Field[ 64 ], T2[ 3 ];
  157.  
  158. db:get_field_assoc( R2, "Expiration", Field, sizeof( Field ) );
  159. if ( !isnull( Field ) )
  160. {
  161. sscanf( Field, "p<|>iii", Time[ 2 ], Time[ 0 ], Time[ 1 ] );
  162.  
  163. gettime( T2[ 0 ], T2[ 1 ] );
  164. getdate( .day = T2[ 2 ] );
  165.  
  166. if ( Time[ 0 ] == 0 ) Time[ 0 ] = 24;
  167. if ( T2[ 2 ] == Time[ 2 ] )
  168. {
  169. if ( T2[ 0 ] == Time[ 0 ] )
  170. {
  171. if ( T2[ 1 ] < Time[ 1 ] )
  172. {
  173. SendClientMessage( playerid, COLOR_RED, "ERROR: You are allowed to gave 1 Like/per hour!" );
  174. format( string, sizeof( string ), "You can repeat the process after %d:%d !", Time[ 0 ], Time[ 1 ] );
  175. SendClientMessage( playerid, COLOR_RED, string );
  176. return 1;
  177. }
  178. }
  179. else if ( T2[ 0 ] < Time[ 0 ] )
  180. {
  181. SendClientMessage( playerid, COLOR_RED, "ERROR: You are allowed to gave 1 Like/per hour!" );
  182. format( string, sizeof( string ), "You can repeat the process after %d:%d !", Time[ 0 ], Time[ 1 ] );
  183. SendClientMessage( playerid, COLOR_RED, string );
  184. return 1;
  185. }
  186. }
  187. }
  188. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Expiration` = '%d|%d|%d' WHERE `Nume` = '%s'", Time[ 2 ], ( Time[ 0 ] == 23 ) ? (0) : ( Time[ 0 ] + 1 ), Time[ 1 ], PlayerName2( playerid ) );
  189. db:query( Database, Query );
  190. }
  191. else db:free_result( R2 );
  192. }
  193. P_DATA[ pViewing[ playerid ] ][ Likes ]++;
  194. GameTextForPlayer( playerid, "~w~Profile ~r~Liked!", 5000, 5 );
  195.  
  196. format( string, sizeof ( string ), "*** FaceBook: {FF9900}%s (ID:%d) {AFAFAF}liked {FF9900}%s (ID:%d){AFAFAF}'s FaceBook profile!", PlayerName2( playerid ), playerid, PlayerName2( pViewing[ playerid ] ), pViewing[ playerid ] );
  197. SendClientMessageToAll( COLOR_GREY, string );
  198. }
  199. if ( dialogid == DELETE )
  200. {
  201. if ( !response ) return 1;
  202.  
  203. new Query[ 256 ];
  204. format( Query, sizeof( Query ), "DELETE FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  205. db:query( Database, Query );
  206. SendClientMessage( playerid, COLOR_RED, "Your facebook account have been succesfully deleted!" );
  207. P_DATA[ playerid ][ Logged ] = 0;
  208. }
  209. if ( dialogid == MOD )
  210. {
  211. if ( response )
  212. {
  213. if ( listitem == 0 )
  214. {
  215. ShowPlayerDialog( playerid, StatusSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Insert the new status what do you want to\n{FF0000}appear on your profile:", "Change", "Back" );
  216. }
  217. if ( listitem == 1 )
  218. {
  219. ShowPlayerDialog( playerid, AgeSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Please insert your age bellow:", "Change", "Back" );
  220. }
  221. if ( listitem == 2 )
  222. {
  223. ShowPlayerDialog( playerid, SexSet, DIALOG_STYLE_LIST, "{FF9900}Select your sex", "{FF0000}Male\n{FFFFFF}Female", "Change", "Back" );
  224. }
  225. if ( listitem == 3 )
  226. {
  227. ShowPlayerDialog( playerid, CountrySet, DIALOG_STYLE_LIST, "{FF9900}Modify", "Romana\nEnglish\nPolsky\nSlovensky\nIntalia\nSpanish\nPortugese\nGerman\nSwedish\nBulgaria\nArab", "Change", "Back" );
  228. }
  229. if ( listitem == 4 )
  230. {
  231. ShowPlayerDialog( playerid, Warning1, DIALOG_STYLE_INPUT, "{FF0000}Reset", "{FF0000}WARNING!: {FFFFFF}Are, you sure to want to reset your FaceBook Likes?", "Yes", "No/Back" );
  232. }
  233. if ( listitem == 5 )
  234. {
  235. ShowPlayerDialog( playerid, Warning2, DIALOG_STYLE_INPUT, "{FF0000}Reset", "{FF0000}WARNING!: {FFFFFF}Are, you sure to want to reset your FaceBook profile Views?", "Yes", "No/Back" );
  236. }
  237. if ( listitem == 6 )
  238. {
  239. ShowPlayerDialog( playerid, OcupationSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Type below what are your ocupation.\nExemple: Dancing", "Change", "Back" );
  240. }
  241. if ( listitem == 7 )
  242. {
  243. ShowPlayerDialog( playerid, PrivacySet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Please type 0 to player can watch your profile\nor type 1 to can't watch your profile!", "Change", "Back" );
  244. }
  245. if ( listitem == 8 )
  246. {
  247. return 1;
  248. }
  249. }
  250. else
  251. {
  252. new str[ 312 ];
  253. strcat( str, "{FFFF00}MODIFY: {FFFFFF}Status\n\
  254. {FFFF00}MODIFY: {FFFFFF}Age\n\
  255. {FFFF00}MODIFY: {FFFFFF}Sex\n\
  256. {FFFF00}MODIFY: {FFFFFF}Country\n\
  257. {FF0000}RESET: {FFFFFF}Likes\n\
  258. {FF0000}RESET: {FFFFFF}Profile Views\n\
  259. {FFFF00}MODIFY: {FFFFFF}Ocupation\n\
  260. {FFFF00}MODIFY: {FFFFFF}Profile Privacy\n\
  261. {FF9900}Exit" );
  262. ShowPlayerDialog( playerid, MOD, DIALOG_STYLE_LIST, "Profile changes", str, "Select", "" );
  263. }
  264. return 1;
  265. }
  266. if ( dialogid == StatusSet )
  267. {
  268. if ( !response ) return FormatFBDialog( playerid );
  269.  
  270. new Query[ 256 ];
  271. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Status` = '%s' WHERE `Nume` = '%s'", inputtext, PlayerName2( playerid ) );
  272. db:query( Database, Query );
  273. GameTextForPlayer( playerid, "~r~Status ~w~ Set!", 5000,5 );
  274. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  275. {
  276. ShowPlayerDialog( playerid, AgeSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Please insert your age bellow:", "Change", "Back" );
  277. }
  278. return 1;
  279. }
  280. if ( dialogid == AgeSet )
  281. {
  282. if ( !response ) return FormatFBDialog( playerid );
  283. if ( sscanf( inputtext, "i", inputtext[ 0 ] ) ) return ShowPlayerDialog( playerid, AgeSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Please insert a correct value!", "Next", "Cancel" );
  284. if ( inputtext[ 0 ] < 0 || inputtext[ 0 ] > 99 ) return ShowPlayerDialog( playerid, DIALOG_STYLE_INPUT, AgeSet, "{FF9900}Modify", "{FF0000}ERROR: {FFFFFF}I don't think you have more that 0 and 99 years!", "Next", "Cancel" );
  285.  
  286. new Query[ 256 ];
  287. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Age` = '%d' WHERE `Nume` = '%s'", inputtext[ 0 ], PlayerName2( playerid ) );
  288. db:query( Database, Query );
  289. GameTextForPlayer( playerid, "~r~Age ~w~Set!", 5000,5 );
  290. P_DATA[ playerid ][ Age ] = inputtext[ 0 ];
  291. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  292. {
  293. ShowPlayerDialog( playerid, SexSet, DIALOG_STYLE_LIST, "{FF9900}Select your sex", "{FF0000}Male\n{FFFFFF}Female", "Change", "Back" );
  294. }
  295. return 1;
  296. }
  297. if ( dialogid == SexSet )
  298. {
  299. if ( !response ) return FormatFBDialog( playerid );
  300. if ( listitem == 0 )
  301. {
  302. new Query[ 256 ];
  303. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Sex` = 'Male' WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  304. db:query( Database, Query );
  305. GameTextForPlayer( playerid, "~r~Sex ~w~Set!", 5000, 5 );
  306. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  307. {
  308. ShowPlayerDialog( playerid, CountrySet, DIALOG_STYLE_LIST, "{FF9900}Modify", "Romana\nEnglish\nPolsky\nSlovensky\nIntalia\nSpanish\nPortugese\nGerman\nSwedish\nBulgaria\nArab", "Change", "Back" );
  309. }
  310. }
  311. if ( listitem == 1 )
  312. {
  313. new Query[ 256 ];
  314. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Sex` = 'Female' WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  315. db:query( Database, Query );
  316. GameTextForPlayer( playerid, "~r~Sex ~w~Set!", 5000, 5 );
  317. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  318. {
  319. ShowPlayerDialog( playerid, CountrySet, DIALOG_STYLE_LIST, "{FF9900}Modify", "Romana\nEnglish\nPolsky\nSlovensky\nIntalia\nSpanish\nPortugese\nGerman\nSwedish\nBulgaria\nArab", "Change", "Back" );
  320. }
  321. }
  322. return 1;
  323. }
  324. if ( dialogid == CountrySet )
  325. {
  326. if ( !response ) return FormatFBDialog( playerid );
  327.  
  328. new Query[ 256 ];
  329. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Country` = '%s' WHERE `Nume` = '%s'", Languages[ listitem ], PlayerName2( playerid ) );
  330. db:query( Database, Query );
  331. GameTextForPlayer( playerid, "~r~Your country have been ~w~Set!", 5000, 5 );
  332. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  333. {
  334. ShowPlayerDialog( playerid, OcupationSet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Type below what are your ocupation.\nExemple: Dancing", "Change", "Back" );
  335. }
  336. return 1;
  337. }
  338. if ( dialogid == Warning1 )
  339. {
  340. if ( !response ) return FormatFBDialog( playerid );
  341. new Query[ 256 ];
  342. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Likes` = '0' WHERE `Nume` = '%s' ", PlayerName2( playerid ) );
  343. db:query( Database, Query );
  344.  
  345. ShowPlayerDialog( playerid, DIALOG_STYLE_MSGBOX, LikesReset, "{FF0000}Reset", "{00FF00}You have reseted your likes", "Back", "" );
  346. P_DATA[ playerid ][ Likes ] = 0;
  347. return 1;
  348. }
  349. if ( dialogid == Warning2 )
  350. {
  351. if ( !response ) return FormatFBDialog( playerid );
  352. new Query[ 256 ];
  353. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Views` = '0' WHERE `Nume` = '%s' ", PlayerName2( playerid ) );
  354. db:query( Database, Query );
  355.  
  356. ShowPlayerDialog( playerid, ViewsReset, DIALOG_STYLE_MSGBOX, "{FF0000}Reset", "{00FF00}You have reseted your profile views!", "Back", "" );
  357. P_DATA[ playerid ][ Views ] = 0;
  358. return 1;
  359. }
  360. if ( dialogid == OcupationSet )
  361. {
  362. if ( !response ) return FormatFBDialog( playerid );
  363. new Query[ 256 ];
  364. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Ocupation` = '%s' WHERE `Nume` = '%s'", inputtext, PlayerName2( playerid ) );
  365. db:query( Database, Query );
  366. GameTextForPlayer( playerid, "~r~Ocupation has been ~w~Set!", 5000, 5 );
  367. if ( GetPVarInt( playerid, "CreatingProfile" ) == 1 )
  368. {
  369. ShowPlayerDialog( playerid, PrivacySet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Do you want to your profile will be private? Type in dialog 1.", "Change", "Back" );
  370. }
  371. return 1;
  372. }
  373. if ( dialogid == PrivacySet )
  374. {
  375. if ( !response ) return FormatFBDialog( playerid );
  376. if ( sscanf( inputtext, "i", inputtext[ 0 ] ) ) return ShowPlayerDialog( playerid, PrivacySet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}Please type only numbers in the dialog!", "Change", "Back" );
  377. if ( inputtext[ 0 ] < 0 || inputtext[ 0 ] > 1 ) return ShowPlayerDialog( playerid, PrivacySet, DIALOG_STYLE_INPUT, "{FF9900}Modify", "{FF0000}ERROR!: Type values between 1 and 0\n{FFFFFF}{FF0000}Please type 0 to player can watch your profile\nor type 1 to can't watch your profile!", "Change", "Back" );
  378.  
  379. new Query[ 256 ];
  380. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Privacy` = '%d' WHERE `Nume` = '%s'", inputtext[ 0 ], PlayerName2( playerid ) );
  381. db:query( Database, Query );
  382. GameTextForPlayer( playerid, "~r~Your privacy profile has been ~w~Set!", 5000, 5 );
  383. P_DATA[ playerid ][ Privacy ] = inputtext[ 0 ];
  384. return 1;
  385. }
  386. if ( dialogid == OnCreateFaceBook )
  387. {
  388. if ( !response ) return 1;
  389. new FPassword[ 128 ];
  390. if ( sscanf( inputtext, "s[128]", FPassword ) ) return ShowPlayerDialog( playerid, OnCreateFaceBook, 1, "{FF9900}New profile", "You need to type a password for create your facebook account!", "Proced", "Cancel" );
  391. if ( strlen( FPassword ) < 3 || strlen( FPassword ) > 24 ) return ShowPlayerDialog( playerid, OnCreateFaceBook, 1, "{FF9900}New profile", "Password is need to be between 3 and 24 caracters!", "Proced", "Cancel" );
  392.  
  393. new Query[ 256 ], str[ 256 ];
  394.  
  395. format( Query, sizeof( Query ), "INSERT INTO `FProfiles` VALUES('%s','%s','N/A','N/A','N/A','0','0','0','N/A','N/A','00|00|00')", PlayerName2( playerid ), FPassword );
  396. db:query( Database, Query );
  397.  
  398. P_DATA[ playerid ][ Logged ] = 1;
  399. SendClientMessage( playerid, GREEN, "You have registred succesfully. Please follow the next step to set your profile: age, status, sex..." );
  400. format( str, sizeof( str ), "{00FF00}Your FaceBook profile was succesfully created with:\nUsername - {FF9900}%s\n{00FF00}Password - {FF9900}%s{00FF00}.\n\nTo change your profile status, ocupation, sex, etc click on 'Settings' button.", PlayerName2( playerid ), FPassword );
  401. ShowPlayerDialog( playerid, OnCreateFaceBook+1, DIALOG_STYLE_MSGBOX, "FaceBook", str, "Settings", "Cancel" );
  402. }
  403. return 1;
  404. }
  405. public OnPlayerConnect( playerid )
  406. {
  407. new Query[ 256 ], DBResult:R;
  408.  
  409. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  410. R = db:query( Database, Query );
  411. if ( R )
  412. {
  413. if ( db:num_rows( R ) )
  414. {
  415. SendClientMessage( playerid, COLOR_RED, "{FFFF00}INFO: {FFFFFF}This user have a FaceBook profile. Use /flogin to login your account!" );
  416. }
  417. else
  418. {
  419. SendClientMessage( playerid, COLOR_RED, "{FFFF00}INFO: {FFFFFF}This user won't have a profile on FaceBook. You can create one with /cfacebook!" );
  420. }
  421. db:free_result( R );
  422. }
  423.  
  424. P_DATA[ playerid ][ Age ] = 0;
  425. P_DATA[ playerid ][ Likes ] = 0;
  426. P_DATA[ playerid ][ Views ] = 0;
  427. P_DATA[ playerid ][ Privacy ] = 0;
  428. P_DATA[ playerid ][ Logged ] = 0;
  429. #if defined Use_Speed_Text
  430. SendClientMessage( playerid, COLOR_ORANGE, "{375FFF}(f)FACEBOOK: {ACACAC}This server use /facebook system by xxSPEEDYxx!" );
  431. #endif
  432. return 1;
  433. }
  434. public OnPlayerDisconnect( playerid, reason )
  435. {
  436. new Query[ 256 ] ;
  437. format( Query, sizeof( Query ), "UPDATE `FProfiles` SET `Likes` = '%d', `Views` = '%d' WHERE `Nume` = '%s'", P_DATA[ playerid ][ Likes ], P_DATA[ playerid ][ Views ], PlayerName2( playerid ) );
  438. db:query( Database, Query );
  439. P_DATA[ playerid ][ Logged ] = 0;
  440. return 1;
  441. }
  442. //============================= [ Commands ] =================================//
  443. CMD:cfacebook( playerid, params[ ] )
  444. {
  445. new Query[ 256 ], DBResult:R;
  446. if ( P_DATA[ playerid ][ Logged ] == 1 ) return SendClientMessage( playerid, COLOR_RED, "You facebook account are already created, and your are logged in!" );
  447.  
  448. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  449. R = db:query( Database, Query );
  450. if ( R )
  451. {
  452. if ( db:num_rows( R ) )
  453. {
  454. SendClientMessage( playerid, COLOR_RED, "ERROR: Your account already exists. Please use {FFFFFF}/flogin to login your facebook account." );
  455. }
  456. else
  457. {
  458. new str[ 256 ];
  459. format( str, sizeof( str ), "{00FF00}Hi {ACACAC}%s{00FF00}, this is a dialog what help you to create\n\
  460. your FaceBook profile...\n\n\
  461. Please type your FaceBook, account password:", PlayerName2( playerid ) );
  462. ShowPlayerDialog( playerid, OnCreateFaceBook, 1, "{FF9900}New profile", str, "Proced", "Cancel" );
  463. }
  464. }
  465. return 1;
  466. }
  467. CMD:facebook( playerid, params[ ] )
  468. {
  469. new Player, str[ 256 ], str2[ 512 ];
  470. if ( sscanf( params, "u", Player ) )
  471. {
  472. if ( P_DATA[ playerid ][ Logged ] == 0 ) return SendClientMessage( playerid, COLOR_RED, "ERROR: You need to be logged in your FB account! Type /flogin [Pass] to login!" );
  473. FormatFBDialog( playerid );
  474. SendClientMessage( playerid, COLOR_GREY, "You watch on your profile. You can also use {FF9900}/facebook [PlayerID]" );
  475. }
  476. else
  477. {
  478. if ( Player == playerid )
  479. {
  480. FormatFBDialog( playerid );
  481. SendClientMessage( playerid, COLOR_GREY, "You watch on your profile. You can also use {FF9900}/facebook [PlayerID]" );
  482. }
  483. else
  484. {
  485. new Query[ 256 ], DBResult:R, DBResult:R2, pField[ 4 ][ 128 ];
  486. if ( !IsPlayerConnected( Player ) ) return SendClientMessage( playerid, COLOR_RED, "ERROR: Player not connected!" );
  487. if ( P_DATA[ Player ][ Privacy ] == 1 ) return SendClientMessage( playerid, COLOR_RED, "Because of a privacy setting on this account, you cannot view this profile." );
  488.  
  489. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( Player ) );
  490. R2 = db:query( Database, Query );
  491. if ( R2 )
  492. {
  493. if ( db:num_rows( R2 ) )
  494. {
  495. format( Query, sizeof( Query ), "SELECT `Status`, `Sex`, `Country`, `Ocupation` FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  496. R = db:query( Database, Query );
  497. if ( R )
  498. {
  499. if ( db:num_rows( R ) )
  500. {
  501. db:get_field_assoc( R, "Status", pField[ 0 ], 128 );
  502. db:get_field_assoc( R, "Sex", pField[ 1 ], 128 );
  503. db:get_field_assoc( R, "Country", pField[ 2 ], 128 );
  504. db:get_field_assoc( R, "Ocupation", pField[ 3 ], 128 );
  505. format( str, sizeof( str ), "{FF0000}%s's FaceBook profile:\n\n\
  506. {FF9900}Status: {00FF00}%s\n\
  507. {FF9900}Age: {00FF00}%d\n\
  508. {FF9900}Sex: {00FF00}%s\n\
  509. {FF9900}Country: {00FF00}%s\n", PlayerName2( Player ), pField[ 0 ], P_DATA[ Player ][ Age ], pField[ 1 ], pField[ 2 ] );
  510. format( str2, sizeof( str2 ), "%s{FF9900}Likes: {00FF00}%d\n\
  511. {FF9900}Profile Views: {00FF00}%d\n\
  512. {FF9900}Ocupation: {00FF00}%s\n\
  513. {FF9900}Privacy Profile: {00FF00}%d\n", str, P_DATA[ Player ][ Likes ], P_DATA[ Player ][ Views ], pField[ 3 ], P_DATA[ Player ][ Privacy ] );
  514. ShowPlayerDialog( playerid, FB, DIALOG_STYLE_MSGBOX, "FaceBook", str2, "Like", "Cancel" );
  515. pViewing[ playerid ] = Player;
  516. P_DATA[ Player ][ Views ]++;
  517. }
  518. else db:free_result( R );
  519. }
  520. }
  521. else return SendClientMessage( playerid, COLOR_RED, "ERROR: This user don't have a facebook account!" );
  522. }
  523. }
  524. }
  525. return 1;
  526. }
  527. CMD:flogin( playerid, params[ ] )
  528. {
  529. if ( P_DATA[ playerid ][ Logged ] == 1 ) return SendClientMessage( playerid, COLOR_RED, "You are already logged on you FaceBook account!" );
  530.  
  531. ShowPlayerDialog( playerid, Dialog_LoginFAccount, DIALOG_STYLE_INPUT, "Login your FaceBook account", "{00FF00}Hi,\nPlease type your facebook password, for login into your account:", "Login", "Cancel" );
  532. return 1;
  533. }
  534. CMD:dfacebook( playerid, params[ ] )
  535. {
  536. new Query[ 256 ], DBResult:R;
  537.  
  538. format( Query, sizeof( Query ), "SELECT * FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  539. R = db:query( Database, Query );
  540. if ( db:num_rows( R ) )
  541. {
  542. if ( P_DATA[ playerid ][ Logged ] == 1 )
  543. {
  544. ShowPlayerDialog( playerid, DELETE, DIALOG_STYLE_MSGBOX, "{FF0000}Delete facebook profile!", "{00FF00}Ar you sure to delete yout FaceBook account?\n\n{FF0000}WARNING!:{00FF00} All profile informations, likes, views will be deleted!\n{00FF00}Contiue operation?", "Yes", "No" );
  545. }
  546. else
  547. {
  548. SendClientMessage( playerid, COLOR_RED, "ERROR: {FFFFFF}You need to be logged in your facebook account to delete it!" );
  549. SendClientMessage( playerid, COLOR_RED, "USAGE: {FFFFFF}/flogin [Password]" );
  550. }
  551. }
  552. else return SendClientMessage( playerid, COLOR_RED, "You don't have a facebook account! To create it type /cfacebook!" );
  553. return 1;
  554. }
  555. CMD:fhelp( playerid, params[ ] )
  556. {
  557. new str[ 400 ];
  558. strcat( str, "{ABFE11}Commands:\n", 256 );
  559. strcat( str, "{FFFFFF}/FACEBOOK - {FF8900}Watch your profile or someone else.\n" );
  560. strcat( str, "{FFFFFF}/CFACEBOOK - {FF8900}Create your facebook profile.\n" );
  561. strcat( str, "{FFFFFF}/DFACEBOOK - {FF8900}Delete your facebook profile.\n" );
  562. strcat( str, "{FFFFFF}/FLOGIN - {FF8900}Login into your facebook profile.\n\n" );
  563. strcat( str, "{ABFE11}Credits:\n" );
  564. strcat( str, "{FFFFFF}xxSPEEDYxx - {FF8900}For making this filterscript.\n" );
  565. strcat( str, "{FFFFFF}[.E.m.O.]K1DDU - {FF8900}For help me on testings this filterscript.\n" );
  566. strcat( str, "{FFFFFF}0Admin( Zh3r0 ) - {FF8900}For make that likes can give once at 1 hour per player");
  567. ShowPlayerDialog( playerid, Dialog_FHelp, DIALOG_STYLE_MSGBOX, "Facebook by xxSPEEDYxx", str, "Quit", "" );
  568. return 1;
  569. }
  570. //=============================== [ Stock's ] ================================//
  571. stock FormatFBDialog( playerid )
  572. {
  573. new Query[ 256 ], str[ 256 ], str2[ 512 ], DBResult:R, pField[ 4 ][ 128 ];
  574. format( Query, sizeof( Query ), "SELECT `Status`, `Sex`, `Country`, `Ocupation` FROM `FProfiles` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
  575. R = db:query( Database, Query );
  576. if ( R )
  577. {
  578. if ( db:num_rows( R ) )
  579. {
  580. db:get_field_assoc( R, "Status", pField[ 0 ], 128 );
  581. db:get_field_assoc( R, "Sex", pField[ 1 ], 128 );
  582. db:get_field_assoc( R, "Country", pField[ 2 ], 128 );
  583. db:get_field_assoc( R, "Ocupation", pField[ 3 ], 128 );
  584. format( str, sizeof( str ), "{FF0000}Your Profile\n\n\
  585. {FF9900}Status: {00FF00}%s\n\
  586. {FF9900}Age: {00FF00}%d\n\
  587. {FF9900}Sex: {00FF00}%s\n\
  588. {FF9900}Country: {00FF00}%s\n", pField[ 0 ], P_DATA[ playerid ][ Age ], pField[ 1 ], pField[ 2 ] );
  589. format( str2, sizeof( str2 ), "%s{FF9900}Likes: {00FF00}%d\n\
  590. {FF9900}Profile Views: {00FF00}%d\n\
  591. {FF9900}Ocupation: {00FF00}%s\n\
  592. {FF9900}Privacy Profile: {00FF00}%d\n", str, P_DATA[ playerid ][ Likes ], P_DATA[ playerid ][ Views ], pField[ 3 ], P_DATA[ playerid ][ Privacy ] );
  593. ShowPlayerDialog( playerid, MYFB, DIALOG_STYLE_MSGBOX, "FaceBook", str2, "Cancel", "Settings" );
  594. }
  595. else db:free_result( R );
  596. }
  597. return 1;
  598. }
  599. stock PlayerName2( i ) { new n[ 24 ]; GetPlayerName( i, n, 24 ); return n; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement