Advertisement
Chainksain

tutorial6.pwn

Apr 15th, 2020
1,623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.80 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <zcmd>
  4. #include <DOF2>
  5.  
  6. #define function%0(%1) forward %0(%1); public %0(%1)
  7.  
  8. new host[16], username[MAX_PLAYER_NAME], database[MAX_PLAYER_NAME], pass[16];
  9.  
  10. main()
  11. {
  12.     print("\n----------------------------------");
  13.     print(" Blank Gamemode by your name here");
  14.     print("----------------------------------\n");
  15. }
  16.  
  17. public OnGameModeInit()
  18. {
  19.     SetGameModeText("Blank Script");
  20.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  21.     LoadMap("maps/favela_objects.txt");
  22.     LoadDBSettings("dbconfig.ini");
  23.     return 1;
  24. }
  25.  
  26. public OnGameModeExit()
  27. {
  28.     DOF2_Exit();
  29.     return 1;
  30. }
  31.  
  32. public OnPlayerRequestClass(playerid, classid)
  33. {
  34.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  35.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  36.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  37.     return 1;
  38. }
  39.  
  40. public OnPlayerConnect(playerid)
  41. {
  42.     RemoveBuildingFromFile(playerid, "maps/favela_buildings.txt");
  43.     return 1;
  44. }
  45.  
  46. public OnPlayerDisconnect(playerid, reason)
  47. {
  48.     new rsnstr[3][] =
  49.     {
  50.         "Timeout/Crash",
  51.         "Saiu",
  52.         "Kickado/Banido"
  53.     };
  54.     new string[64];
  55.     format(string, sizeof(string), "%s foi desconectado (%s)", GetPlayerNameEx(playerid), rsnstr[reason]);
  56.     SendClientMessageToAll(-1, string);
  57.     return 1;
  58. }
  59.  
  60. public OnPlayerSpawn(playerid)
  61. {
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerDeath(playerid, killerid, reason)
  66. {
  67.     return 1;
  68. }
  69.  
  70. public OnVehicleSpawn(vehicleid)
  71. {
  72.     return 1;
  73. }
  74.  
  75. public OnVehicleDeath(vehicleid, killerid)
  76. {
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerText(playerid, text[])
  81. {
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  86. {
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerExitVehicle(playerid, vehicleid)
  91. {
  92.     return 1;
  93. }
  94.  
  95. public OnPlayerStateChange(playerid, newstate, oldstate)
  96. {
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerEnterCheckpoint(playerid)
  101. {
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerLeaveCheckpoint(playerid)
  106. {
  107.     return 1;
  108. }
  109.  
  110. public OnPlayerEnterRaceCheckpoint(playerid)
  111. {
  112.     return 1;
  113. }
  114.  
  115. public OnPlayerLeaveRaceCheckpoint(playerid)
  116. {
  117.     return 1;
  118. }
  119.  
  120. public OnRconCommand(cmd[])
  121. {
  122.     return 1;
  123. }
  124.  
  125. public OnPlayerRequestSpawn(playerid)
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnObjectMoved(objectid)
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerObjectMoved(playerid, objectid)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnPlayerPickUpPickup(playerid, pickupid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnVehicleMod(playerid, vehicleid, componentid)
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnPlayerSelectedMenuRow(playerid, row)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerExitedMenu(playerid)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnRconLoginAttempt(ip[], password[], success)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnPlayerUpdate(playerid)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnPlayerStreamIn(playerid, forplayerid)
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerStreamOut(playerid, forplayerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnVehicleStreamIn(vehicleid, forplayerid)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnVehicleStreamOut(vehicleid, forplayerid)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  221. {
  222.     return 1;
  223. }
  224.  
  225. // FUNCOES
  226.  
  227. function RemoveBuildingFromFile(playerid, const file[])
  228. {
  229.     new File:map = fopen(file, io_read);
  230.     if(map)
  231.     {
  232.         new string[256];
  233.         while(fread(map, string))
  234.         {
  235.             new modelid, Float:pos[3], Float:rad;
  236.             if(!sscanf(string, "dffff", modelid, pos[0], pos[1], pos[2], rad))
  237.                 RemoveBuildingForPlayer(playerid, modelid, pos[0], pos[1], pos[2], rad);
  238.             else
  239.                 return printf("Carregamento do mapa '%s' falhou para o jogador %s(%d).", file, GetPlayerNameEx(playerid), playerid);
  240.         }
  241.     }
  242.     return printf("Jogador %s(%d) carregou o mapa '%s' com êxito.", GetPlayerNameEx(playerid), playerid, file);
  243. }
  244.  
  245. function LoadMap(const file[])
  246. {
  247.     printf("Carregando Mapa '%s'...", file);
  248.     new File:map = fopen(file, io_read);
  249.     if(map)
  250.     {
  251.         new string[256];
  252.         while(fread(map, string))
  253.         {
  254.             new modelid, Float:pos[3], Float:rot[3];
  255.             if(sscanf(string, "dffffff", modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]))
  256.                 return printf("Erro ao carregar o mapa '%s'!",file);
  257.             else
  258.                 CreateObject(modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
  259.                
  260.         }
  261.         return printf("Mapa '%s' carregado com sucesso!",file);
  262.     }
  263.     else return printf("Erro ao carregar o mapa '%s'!",file);
  264. }
  265.  
  266. // COMANDOS
  267.  
  268. CMD:pos(playerid, const params[])
  269. {
  270.     new Float:pos[3], giveplayerid;
  271.     if(sscanf(params, "ufff", giveplayerid, pos[0], pos[1], pos[2]))
  272.         return SendClientMessage(playerid, -1, "USO: /pos [id] [x] [y] [z]");
  273.  
  274.     if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID)
  275.         return SendClientMessage(playerid, -1, "ERRO: ID Inválido!");
  276.  
  277.     SetPlayerPos(giveplayerid, pos[0], pos[1], pos[2]);
  278.     return 1;
  279. }
  280.  
  281. CMD:info(playerid, const params[])
  282. {
  283.     new giveplayerid, string[64];
  284.    
  285.     if(sscanf(params, "u", giveplayerid))
  286.         return SendClientMessage(playerid, -1, "USO: /info [id]");
  287.    
  288.     if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID)
  289.         return SendClientMessage(playerid, -1, "ERRO: ID Inválido!");
  290.  
  291.     format(string, sizeof(string), "Jogador: %s", GetPlayerNameEx(giveplayerid));
  292.     SendClientMessage(playerid, -1, string);
  293.  
  294.     format(string, sizeof(string), "ID: %d", giveplayerid);
  295.     SendClientMessage(playerid, -1, string);
  296.  
  297.     format(string, sizeof(string), "Score: %d", GetPlayerScore(giveplayerid));
  298.     SendClientMessage(playerid, -1, string);
  299.  
  300.     format(string, sizeof(string), "Dinheiro: %d", GetPlayerMoney(giveplayerid));
  301.     SendClientMessage(playerid, -1, string);
  302.        
  303.     format(string, sizeof(string), "Life: %f", GetPlayerHealthEx(giveplayerid));
  304.     SendClientMessage(playerid, -1, string);
  305.  
  306.     format(string, sizeof(string), "Armor: %f", GetPlayerArmourEx(giveplayerid));
  307.     SendClientMessage(playerid, -1, string);
  308.  
  309.     new Float:pos[3];
  310.     GetPlayerPos(giveplayerid, pos[0], pos[1], pos[2]);
  311.     format(string, sizeof(string), "PosX: %f PosY: %f PosZ: %f", pos[0], pos[1], pos[2]);
  312.     SendClientMessage(playerid, -1, string);
  313.  
  314.     format(string, sizeof(string),"Int: %d", GetPlayerInterior(giveplayerid));
  315.     SendClientMessage(playerid, -1, string);
  316.  
  317.     format(string, sizeof(string),"Virtual World: %d", GetPlayerVirtualWorld(giveplayerid));
  318.     SendClientMessage(playerid, -1, string);
  319.  
  320.     return 1;
  321. }
  322.  
  323. // PROCEDIMENTOS
  324.  
  325. stock LoadDBSettings(filename[])
  326. {
  327.     //new host[16], username[MAX_PLAYER_NAME], database[MAX_PLAYER_NAME], pass[16];
  328.     if(DOF2_FileExists(filename))
  329.     {
  330.         format(host, sizeof(host), "%s", DOF2_GetString(filename,"address"));
  331.         format(username, sizeof(username), "%s", DOF2_GetString(filename,"username"));
  332.         format(database, sizeof(database), "%s", DOF2_GetString(filename,"database"));
  333.         format(pass, sizeof(pass), "%s", DOF2_GetString(filename,"password"));
  334.     }
  335.     else
  336.     {
  337.         DOF2_CreateFile(filename);
  338.         DOF2_SetString(filename,"address","127.0.0.1");
  339.         DOF2_SetString(filename,"username","root");
  340.         DOF2_SetString(filename,"database", " ");
  341.         DOF2_SetString(filename,"password", " ");
  342.         DOF2_SaveFile();
  343.     }
  344. }
  345.  
  346. stock GetPlayerNameEx(playerid)
  347. {
  348.     new PlayerName[MAX_PLAYER_NAME];
  349.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  350.     return PlayerName;
  351. }
  352.  
  353. function Float:GetPlayerHealthEx(playerid)
  354. {
  355.     new Float:health;
  356.     GetPlayerHealth(playerid, health);
  357.     return health;
  358. }
  359.  
  360. function Float:GetPlayerArmourEx(playerid)
  361. {
  362.     new Float:armor;
  363.     GetPlayerArmour(playerid, armor);
  364.     return armor;
  365. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement