Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- #include <sscanf2>
- #include <zcmd>
- #include <DOF2>
- #define function%0(%1) forward %0(%1); public %0(%1)
- new MySQL:DBConn, host[16], username[MAX_PLAYER_NAME], database[MAX_PLAYER_NAME], pass[16];
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- public OnGameModeInit()
- {
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- LoadMap("maps/favela_objects.txt");
- DataBaseInit();
- return 1;
- }
- public OnGameModeExit()
- {
- DOF2_Exit();
- mysql_close(DBConn);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- RemoveBuildingFromFile(playerid, "maps/favela_buildings.txt");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new rsnstr[3][] =
- {
- "Timeout/Crash",
- "Saiu",
- "Kickado/Banido"
- };
- new string[64];
- format(string, sizeof(string), "%s foi desconectado (%s)", GetPlayerNameEx(playerid), rsnstr[reason]);
- SendClientMessageToAll(-1, string);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
- {
- return 1;
- }
- // FUNCOES
- function DataBaseInit()
- {
- //new MYSQL:DBConn, host[16], username[MAX_PLAYER_NAME], database[MAX_PLAYER_NAME], pass[16];
- LoadDBSettings("dbconfig.ini");
- DBConn = mysql_connect(host, username, pass, database);
- if(mysql_errno() == 0)
- {
- printf("[MySQL] Database '%s' conectada com sucesso!", database);
- print("[MySQL] Verificando tabelas...");
- mysql_query(DBConn, "CREATE TABLE IF NOT EXISTS Player (\
- id int NOT NULL AUTO_INCREMENT,\
- nome varchar(25) NOT NULL,\
- senha varchar(255) NOT NULL,\
- admin int DEFAULT 0,\
- PRIMARY KEY(id));", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS health float DEFAULT 100;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS armor float DEFAULT 100;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS dinheiro int DEFAULT 100;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS posX double DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS posY double DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS posZ double DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS angulo double DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS interior int DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS vw int DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS score int DEFAULT 0;", false);
- mysql_query(DBConn, "ALTER TABLE Player ADD IF NOT EXISTS skin int DEFAULT 0;", false);
- print("[MySQL] Tabela 'Players' verificada com sucesso!");
- }
- else
- {
- printf("[MySQL] ERRO: Não foi possível se conectar a database '%s'!", database);
- SendRconCommand("exit");
- }
- return 1;
- }
- function RemoveBuildingFromFile(playerid, const file[])
- {
- new File:map = fopen(file, io_read);
- if(map)
- {
- new string[256];
- while(fread(map, string))
- {
- new modelid, Float:pos[3], Float:rad;
- if(!sscanf(string, "dffff", modelid, pos[0], pos[1], pos[2], rad))
- RemoveBuildingForPlayer(playerid, modelid, pos[0], pos[1], pos[2], rad);
- else
- return printf("Carregamento do mapa '%s' falhou para o jogador %s(%d).", file, GetPlayerNameEx(playerid), playerid);
- }
- }
- return printf("Jogador %s(%d) carregou o mapa '%s' com êxito.", GetPlayerNameEx(playerid), playerid, file);
- }
- function LoadMap(const file[])
- {
- printf("Carregando Mapa '%s'...", file);
- new File:map = fopen(file, io_read);
- if(map)
- {
- new string[256];
- while(fread(map, string))
- {
- new modelid, Float:pos[3], Float:rot[3];
- if(sscanf(string, "dffffff", modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]))
- return printf("Erro ao carregar o mapa '%s'!",file);
- else
- CreateObject(modelid, pos[0], pos[1], pos[2], rot[0], rot[1], rot[2]);
- }
- return printf("Mapa '%s' carregado com sucesso!",file);
- }
- else return printf("Erro ao carregar o mapa '%s'!",file);
- }
- // COMANDOS
- CMD:pos(playerid, const params[])
- {
- new Float:pos[3], giveplayerid;
- if(sscanf(params, "ufff", giveplayerid, pos[0], pos[1], pos[2]))
- return SendClientMessage(playerid, -1, "USO: /pos [id] [x] [y] [z]");
- if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID)
- return SendClientMessage(playerid, -1, "ERRO: ID Inválido!");
- SetPlayerPos(giveplayerid, pos[0], pos[1], pos[2]);
- return 1;
- }
- CMD:info(playerid, const params[])
- {
- new giveplayerid, string[64];
- if(sscanf(params, "u", giveplayerid))
- return SendClientMessage(playerid, -1, "USO: /info [id]");
- if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID)
- return SendClientMessage(playerid, -1, "ERRO: ID Inválido!");
- format(string, sizeof(string), "Jogador: %s", GetPlayerNameEx(giveplayerid));
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "ID: %d", giveplayerid);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Score: %d", GetPlayerScore(giveplayerid));
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Dinheiro: %d", GetPlayerMoney(giveplayerid));
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Life: %f", GetPlayerHealthEx(giveplayerid));
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "Armor: %f", GetPlayerArmourEx(giveplayerid));
- SendClientMessage(playerid, -1, string);
- new Float:pos[3];
- GetPlayerPos(giveplayerid, pos[0], pos[1], pos[2]);
- format(string, sizeof(string), "PosX: %f PosY: %f PosZ: %f", pos[0], pos[1], pos[2]);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string),"Int: %d", GetPlayerInterior(giveplayerid));
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string),"Virtual World: %d", GetPlayerVirtualWorld(giveplayerid));
- SendClientMessage(playerid, -1, string);
- return 1;
- }
- // PROCEDIMENTOS
- stock LoadDBSettings(filename[])
- {
- //new host[16], username[MAX_PLAYER_NAME], database[MAX_PLAYER_NAME], pass[16];
- if(DOF2_FileExists(filename))
- {
- format(host, sizeof(host), "%s", DOF2_GetString(filename,"address"));
- format(username, sizeof(username), "%s", DOF2_GetString(filename,"username"));
- format(database, sizeof(database), "%s", DOF2_GetString(filename,"database"));
- format(pass, sizeof(pass), "%s", DOF2_GetString(filename,"password"));
- }
- else
- {
- DOF2_CreateFile(filename);
- DOF2_SetString(filename,"address","127.0.0.1");
- DOF2_SetString(filename,"username","root");
- DOF2_SetString(filename,"database", " ");
- DOF2_SetString(filename,"password", " ");
- DOF2_SaveFile();
- }
- }
- stock GetPlayerNameEx(playerid)
- {
- new PlayerName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
- return PlayerName;
- }
- function Float:GetPlayerHealthEx(playerid)
- {
- new Float:health;
- GetPlayerHealth(playerid, health);
- return health;
- }
- function Float:GetPlayerArmourEx(playerid)
- {
- new Float:armor;
- GetPlayerArmour(playerid, armor);
- return armor;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement