Olá galera boa tarde a todos, enfim um inscrito meu me disse que no mundo da programação oque falta é teste para os programadores.
Então com este intuito vim trazer um gamemode com alguns bugs simples porém difíceis de ser achados e com horríveis optimizações de programação.
Este é o teste para os programadores, o programador que melhor se sobressair neste teste irá ser marcado no blog !
Boa sorte a todos.
#include <a_samp>
#include <DOF2>
//defines
#define cinza 0x708090FF
#define verde 0x228B22FF
#define laranja 0xFF4500FF
#define azul 0x1874CDAA
#define vermelho 0xFF0000AA
#define DIALOG_REG 1
#define DIALOG_LOG 2
//forwards forward kikar(playerid); forward hora(playerid); forward msgon(playerid); forward registrando(playerid);
//enums enum Informacoes {
pSenha,
pDinheiro,
pHabTerrestre,
pHabAquatica,
pHabAerea,
pExp,
pLevel,
pCel,
pOculos,
pBone,
pVip,
pMesesVip,
pSaldoBanco,
pMultas,
pVMultas,
pRelogio,
pProcurado,
pEstrelasProcurado,
pAvisos,
pProf,
pSkin,
pPreso,
pTempoPreso,
pMotivoPreso,
pQuemPrendeu,
pBanido,
pMotivoBanido,
pFome,
pSede,
pSono,
pVida,
pPosicao,
pCapacete,
pIp,
pHelper,
pAdmin,
pNovato }
// news new Text:Textdraw0;
new Text:Textdraw1;
new Player[MAX_PLAYERS][Informacoes];
new Logado[MAX_PLAYER_NAME] = 0;
main()
{
print("\n----------------------------------");
print("GM carregado com suceso.");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SendRconCommand("hostname Brasil Vida Real ® | RPG SERVER | #BrasilPortugal");
SendRconCommand("mapname Brasil Vida Real");
SendRconCommand("changemode Brasil - BVR RPG v1.0.0");
SendRconCommand("weburl www.mathservers.com.br");
SetGameModeText("Brasil - BVR RPG v1.0.0");
SendRconCommand("language Português - Brasil");
SetWeather(14);
Textdraw0 = TextDrawCreate(491.000000, 129.000000, "00:00:00");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, -1);
TextDrawSetOutline(Textdraw0, 0);
TextDrawSetProportional(Textdraw0, 1);
TextDrawSetShadow(Textdraw0, 1);
Textdraw1 = TextDrawCreate(489.000000, 115.000000, "00/00/00");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
TextDrawColor(Textdraw1, -1);
TextDrawSetOutline(Textdraw1, 0);
TextDrawSetProportional(Textdraw1, 1);
TextDrawSetShadow(Textdraw1, 1);
SetTimer("hora",1000,1);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerFacingAngle(playerid, 180);
SetPlayerPos(playerid, -2624.4458, 1421.1406, 24.0000);
SetPlayerCameraPos(playerid, -2620.6990, 1413.6143, 25.8391);
SetPlayerCameraLookAt(playerid, -2621.2310, 1414.4666, 25.8341);
return 1;
}
public OnPlayerConnect(playerid)
{
AddPlayerClass(154, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
PlayAudioStreamForPlayer(playerid, "http://habeta.com.br/preview.mp3");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid, azul, "| INFO | Aguarde... carregando os dados!");
SetPlayerFacingAngle(playerid, 180);
SetPlayerPos(playerid, -2624.4458, 1421.1406, 24.0000);
SetPlayerCameraPos(playerid, -2620.6990, 1413.6143, 25.8391);
SetPlayerCameraLookAt(playerid, -2621.2310, 1414.4666, 25.8341);
AddPlayerClass(154, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Logado[playerid] = 0;
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
SetPlayerColor(playerid, 0xFFFFFFFF);
SetTimer("msgon", 1500, false);
new arquivo[40], aname[MAX_PLAYER_NAME], str[156], str2[156];
GetPlayerName(playerid, aname, 25);
format(arquivo, sizeof(arquivo), "Contas/%s.ini", aname);
format(str, sizeof(str), "{4169E1}Usuário: {FFFFFF}%s\n\n{FFFFFF}Conta: {32CD32}Registrada\n\n{FFFFFF}Informe sua senha:", aname);
format(str2, sizeof(str2), "{4169E1}Usuário: {FFFFFF}%s\n\n{FFFFFF}Conta: {FF4500}Não registrada\n\n{FFFFFF}Digite uma senha:", aname);
if(DOF2_FileExists(arquivo))
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "{FF0000}Conta", str, "Logar", "Sair");
}else{
ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "{FF0000}Registro", str2, "Registrar", "Sair");
AddPlayerClass(154, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
(Logado[playerid] = 0);
DOF2_Exit();
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Logado[playerid] == 1)
{
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid, -1, "| CONTA | Logado com sucesso!");
StopAudioStreamForPlayer(playerid);
}else{
SendClientMessage(playerid, -1, "{FF0000}| LOGIN | Você não fez login e tentou burlar o sistema.");
SetTimer("kikar", 250, false);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
new str[250], aname[20];
GetPlayerName(playerid, aname, sizeof(aname));
format(str, sizeof(str), "%s: [%d] %s",aname, playerid, text);
if(Logado[playerid] == 1)
{
SendClientMessageToAll(-1, str);
}else{
SendClientMessage(playerid, laranja, "| ERRO | Faça o login antes de conversar.");
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(Logado[playerid] == 1)
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return SendClientMessage(playerid, laranja, "| ERRO | Digite: /Ajuda Level, Salario, Comandos, Contato, Casa, Empresa, Carro, Loteria, Concessionaria, Mercadoria");
}else{
SendClientMessage(playerid, laranja, "| ERRO | Logue antes de usar os comandos.");
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[])
{
new arquivo[40], aname[MAX_PLAYER_NAME], str[156], str2[156], ip[30];
GetPlayerName(playerid, aname, 25);
format(arquivo, sizeof(arquivo), "Contas/%s.ini", aname);
format(str, sizeof(str), "{4169E1}Usuário: {FFFFFF}%s\n\n{FFFFFF}Conta: {32CD32}Registrada\n\n{FFFFFF}Informe sua senha:", aname);
format(str2, sizeof(str2), "{4169E1}Usuário: {FFFFFF}%s\n\n{FFFFFF}Conta: {FF4500}Não registrada\n\n{FFFFFF}Digite uma senha:", aname);
if(dialogid == DIALOG_REG)
{
AddPlayerClass(154, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SetPlayerFacingAngle(playerid, 180);
SetPlayerPos(playerid, -2624.4458, 1421.1406, 24.0000);
SetPlayerCameraPos(playerid, -2620.6990, 1413.6143, 25.8391);
SetPlayerCameraLookAt(playerid, -2621.2310, 1414.4666, 25.8341);
if(strlen(inputtext) < 5){
SendClientMessage(playerid, laranja, "| ERRO | Você digitou uma senha muito pequena! (Ela precisa ter entre 5 e 15 caracteres)");
ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "{FF0000}Registro", str2, "Registrar", "Sair");
}
if(strlen(inputtext) > 15){
SendClientMessage(playerid, laranja, "| ERRO | Você digitou uma senha muito grande! (Ela precisa ter entre 5 e 15 caracteres)");
ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD, "{FF0000}Registro", str2, "Registrar", "Sair");
}
if(!response)
{
SendClientMessage(playerid, -1, "{FF0000}| REGISTRO | Você cancelou o registro e por este motivo foi kikado.");
SetTimer("kikar", 250, false);
return 1;
}
else
{
GetPlayerIp(playerid, Player[playerid][pIp], 156);
format(ip, sizeof(ip), "%i");
SendClientMessage(playerid, -1, "{32CD32}| INFO | {1874CD}Efetuando registro...");
GameTextForPlayer(playerid, "~b~Carregando...", 5000, 5);
DOF2_CreateFile(arquivo);
DOF2_SetString(arquivo, "Senha", (inputtext));
DOF2_SetInt(arquivo, "Dinheiro", 560);
DOF2_SetInt(arquivo, "HabilitacaoTerrestre", 0);
DOF2_SetInt(arquivo, "HabilitacaoAquatica", 0);
DOF2_SetInt(arquivo, "HabilitacaoAerea", 0);
DOF2_SetInt(arquivo, "Experiencia", 0);
DOF2_SetInt(arquivo, "Level", 0);
DOF2_SetInt(arquivo, "Celular", 0);
DOF2_SetInt(arquivo, "Oculos", 0);
DOF2_SetInt(arquivo, "Bone", 0);
DOF2_SetInt(arquivo, "Vip", 0);
DOF2_SetInt(arquivo, "MesesVip", 0);
DOF2_SetInt(arquivo, "Saldo", 0);
DOF2_SetInt(arquivo, "Multas", 0);
DOF2_SetInt(arquivo, "ValorMultas", 0);
DOF2_SetInt(arquivo, "Relogio", 0);
DOF2_SetInt(arquivo, "Procurado", 0);
DOF2_SetInt(arquivo, "EstrelasProcurado", 0);
DOF2_SetInt(arquivo, "Avisos", 0);
DOF2_SetInt(arquivo, "Profissao", 0);
DOF2_SetInt(arquivo, "Skin", 154);
DOF2_SetInt(arquivo, "Preso", 0);
DOF2_SetInt(arquivo, "TempoPreso", 0);
DOF2_SetInt(arquivo, "MotivoPreso", 0);
DOF2_SetInt(arquivo, "QuemPrendeu", 0);
DOF2_SetInt(arquivo, "Banido", 0);
DOF2_SetInt(arquivo, "MotivoBan", 0);
DOF2_SetInt(arquivo, "Fome", 100);
DOF2_SetInt(arquivo, "Sede", 100);
DOF2_SetInt(arquivo, "Sono", 100);
DOF2_SetInt(arquivo, "Vida", 100);
DOF2_SetInt(arquivo, "Capacete", 0);
DOF2_SetString(arquivo, "Ip", Player[playerid][pIp]);
DOF2_SetInt(arquivo, "Helper", 0);
DOF2_SetInt(arquivo, "Admin", 0);
DOF2_SetInt(arquivo, "Novato", 1);
DOF2_SetInt(arquivo, "Posicao", 0);
SetTimer("registrando", 5000, false);
return 1;
}
}
if(dialogid == DIALOG_LOG)
{
AddPlayerClass(154, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
SetPlayerFacingAngle(playerid, 180);
SetPlayerPos(playerid, -2624.4458, 1421.1406, 24.0000);
SetPlayerCameraPos(playerid, -2620.6990, 1413.6143, 25.8391);
SetPlayerCameraLookAt(playerid, -2621.2310, 1414.4666, 25.8341);
if(strlen(inputtext) < 5)
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "{FF0000}Conta", str, "Logar", "Sair");
SendClientMessage(playerid, laranja, "| ERRO | Senha inválida! (Possui menos de 5 caracteres)");
return 1;
}
if(strlen(inputtext) > 15)
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "{FF0000}Conta", str, "Logar", "Sair");
SendClientMessage(playerid, laranja, "| ERRO | Senha inválida! (Possui mais de 15 caracteres)");
return 1;
}
if(!response)
{
SendClientMessage(playerid, -1, "{FF0000}| LOGIN | Você cancelou o login, por isso foi kikado!");
SetTimer("kikar", 250, false);
return 1;
}else{
format(arquivo, sizeof(arquivo), "contas/%s.ini", aname);
if(!strcmp(inputtext,DOF2_GetString(arquivo,"Senha"),false))
{
SendClientMessage(playerid, -1, "{32CD32}| INFO | {FFFFFF}Você entrou na sua conta com sucesso! Clique em spawn para jogar.");
GameTextForPlayer(playerid, "~b~CLIQUE EM SPAWN~w~~d~", 5000, 5);
Logado[playerid] = 1;
return 1;
}else{
SendClientMessage(playerid, vermelho, "| LOGIN | Senha incorreta!");
SetTimer("kikar", 250, false);
return 1;
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public hora(playerid)
{
new str[128], str2[128], year, month, day, hour, minute, second;
getdate(year, month, day);
gettime(hour,minute,second);
if(hour == 21) {SetWorldTime(00);}
if(hour == 22) {SetWorldTime(00);}
if(hour == 23) {SetWorldTime(00);}
if(hour == 00) {SetWorldTime(00);}
if(hour == 01) {SetWorldTime(01);}
if(hour == 02) {SetWorldTime(02);}
if(hour == 03) {SetWorldTime(03);}
if(hour == 04) {SetWorldTime(04);}
if(hour == 05) {SetWorldTime(05);}
if(hour == 06) {SetWorldTime(06);}
if(hour == 07) {SetWorldTime(07);}
if(hour == 0 ){SetWorldTime(0);}
if(hour == 09) {SetWorldTime(09);}
if(hour == 10) {SetWorldTime(10);}
if(hour == 11) {SetWorldTime(11);}
if(hour == 12) {SetWorldTime(12);}
if(hour == 13) {SetWorldTime(13);}
if(hour == 14) {SetWorldTime(14);}
if(hour == 15) {SetWorldTime(15);}
if(hour == 16) {SetWorldTime(19);}
if(hour == 17) {SetWorldTime(20);}
if(hour == 1 ){SetWorldTime(20);}
if(hour == 19) {SetWorldTime(21);}
if(hour == 20) {SetWorldTime(22);}
new mes[12];
if(month == 1) { mes = "janeiro"; }
else if(month == 2) {mes = "fevereiro";}
else if(month == 3) {mes = "março";}
else if(month == 4) {mes = "abril";}
else if(month == 5) {mes = "maio";}
else if(month == 6) {mes = "junho";}
else if(month == 7) {mes = "julho";}
else if(month == 8) {mes = "agosto";}
else if(month == 9) {mes = "setembro";}
else if(month == 10) {mes = "outubro";}
else if(month == 11) {mes = "novembro";}
else if(month == 12) {mes= "dezembro";}
format(str, sizeof(str), "%d de %s de %d", day, mes,year);
TextDrawSetString(Text:Textdraw0, str);
format(str2, sizeof(str2), "%d:0%d", hour, minute);
TextDrawSetString(Text:Textdraw1, str2);
}
public msgon(playerid)
{
SetPlayerFacingAngle(playerid, 180);
SetPlayerPos(playerid, -2624.4458, 1421.1406, 24.0000);
SetPlayerCameraPos(playerid, -2620.6990, 1413.6143, 25.8391);
SetPlayerCameraLookAt(playerid, -2621.2310, 1414.4666, 25.8341);
new str[156], aname[20];
GetPlayerName(playerid, aname, sizeof(aname));
format(str, sizeof(str), "» Bem vindo(a) ao servidor Brasil Vida Real,'{228B22}%s{FFFFFF}' ", aname);
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid,-1, " ");
SendClientMessage(playerid, cinza, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~");
SendClientMessage(playerid, -1, str);
SendClientMessage(playerid, -1, "» Para ver os comandos do servidor Digite: /Ajuda Comandos");
SendClientMessage(playerid, cinza, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~");
return 1;
}
public kikar(playerid)
{
Kick(playerid);
return 1;
}
public registrando(playerid)
{
new str[156], aname[25];
GetPlayerName(playerid, aname, 25);
format(str, sizeof(str), "{4169E1}Usuário: {FFFFFF}%s\n\n{FFFFFF}Conta: {32CD32}Registrada\n\n{FFFFFF}Informe sua senha:", aname);
SendClientMessage(playerid, -1, "{32CD32}| INFO | {FFFFFF}Conta registrada com sucesso! Logue para poder jogar.");
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD, "{FF0000}Conta", str, "Logar", "Sair");
return 1;
}