AXV09

Untitled

May 7th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3. #include <mysql>
  4. #include <sscanf2>
  5. #include <Zcmd>
  6.  
  7. //definy
  8. #define MAX_SPAWN 200 //można powiększać...
  9. //zmienne
  10. new sprawdzaneid;
  11. //enumy
  12. enum randomspawn { Float: vpos[4] };
  13.  
  14. //tablice do enumów
  15. new rspawn[MAX_SPAWN][randomspawn];
  16. //
  17. public OnGameModeInit()
  18. {
  19. new MySQL:connection = mysql_init(LOG_ONLY_ERRORS, 1);
  20. mysql_connect("192.166.219.226", "Shalp3y", "*******************", "Shalp3y", connection, 1);
  21. SetGameModeText("Spawnsy");
  22. LoadSpawn();
  23. return 1;
  24. }
  25. public OnGameModeExit()
  26. {
  27. return 1;
  28. }
  29. public OnPlayerRequestClass(playerid, classid)
  30. {
  31. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  32. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  33. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  34. return 1;
  35. }
  36.  
  37. public OnPlayerSpawn(playerid)
  38. {
  39. new rand = random(gTotalRandomSpawn);
  40. if (!rand) rand=1; // aqq
  41. SetPlayerPosEx( playerid, rspawn[ rand ][ vpos ][ 0 ],
  42. rspawn[ rand ][ vpos ][ 1 ],
  43. rspawn[ rand ][ vpos ][ 2 ],
  44. rspawn[ rand ][ vpos ][ 3 ] );
  45. return 1;
  46. }
  47.  
  48. stock LoadSpawn( ) {
  49. gTotalRandomSpawn = 0;
  50.  
  51. new i, query[ 128 ]; // 10000 o_0
  52. format( query, sizeof( query ), "SELECT x,y,z,rot FROM `rand_spawn`" );
  53. mysql_query( query );
  54. mysql_store_result( );
  55. while( mysql_fetch_row( query, "|" ) ) {
  56. sscanf( query, "p<|>ffff",
  57. rspawn[ i ][ vpos ][ 0 ],
  58. rspawn[ i ][ vpos ][ 1 ],
  59. rspawn[ i ][ vpos ][ 2 ],
  60. rspawn[ i ][ vpos ][ 3 ] );
  61. i++;
  62. }
  63. gTotalRandomSpawn=i+1; // omijamy 0 (wartosc testowa)
  64. printf( "Zaladowano %d spawnow.", i+1 );
  65. return i;
  66. }
  67.  
  68. CMD:dodajspawn( playerid, params[ ] ) {
  69.  
  70. new query[ 160 ],
  71. Float: x,
  72. Float: y,
  73. Float: z,
  74. Float: a
  75. ;
  76.  
  77. GetPlayerPos( playerid, x, y, z );
  78. GetPlayerFacingAngle( playerid, a );
  79. format( query, sizeof( query ), "INSERT INTO `rand_spawn` ( x,y,z,rot ) VALUES ( '%4.3f', '%4.3f', '%4.2f', '%2.3f' );", x, y, z, a );
  80. mysql_query(query);
  81. LoadSpawn();
  82. return 1;
  83. }
  84.  
  85. CMD:sprawdz( playerid, params[ ] ) {
  86. new string[ 64 ];
  87. format(string, sizeof(string), "%f", rspawn[ strval( params ) ][ vpos ][ 0 ]);
  88. SendClientMessage(playerid, -1, string);
  89. return 1;
  90. }
  91.  
  92. stock SetPlayerPosEx( playerid, Float:x, Float:y, Float:z, Float:ang ) {
  93. SetPlayerPos( playerid, x, y, z );
  94. SetPlayerFacingAngle( playerid, ang );
  95. return 1;
  96. }
  97.  
  98.  
  99. /*
  100. struktura
  101.  
  102. create table if not exist rand_spawn (
  103. id int(11) not null auto_increment,
  104. x varchar(16) not null default '0.0',
  105. y varchar(16) not null default '0.0',
  106. z varchar(12) not null default '0.0',
  107. rot varchar(12) not null default '0.0',
  108. primary key (`id`)
  109. ) engine=myisam auto_increment=0;
  110.  
  111. insert into rand_spawn ( x,y,z,rot ) values ( '0.0', '0.0', '0.0', '0.0' );
  112.  
  113. */
Advertisement
Add Comment
Please, Sign In to add comment