// Includes #include <a_samp> #include <Dini> #include <foreach> // Anulando #pragma tabsize 0 #pragma unused strtok #pragma unused ret_memcpy // Defines #define REGISTRO 1 #define LOGIN 2 #define CONTAS "Contas/%s.ini" // Variaveis new Matou[MAX_PLAYERS]; new Morreu[MAX_PLAYERS]; new Logou[MAX_PLAYERS]; new Exp[MAX_PLAYERS]; new Level[MAX_PLAYERS]; //Forwards forward GanharExp(); main() { print("\n----------------------------------"); print(" Brasil Ultra City RPG "); print("----------------------------------\n"); } public OnGameModeInit() { foreach(Player, i){ } SetTimer("GanharExp", 600000, 1); SetGameModeText("BUC: PT/BR"); AddPlayerClass(22, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; } public OnGameModeExit() { for(new i=0; i<MAX_PLAYERS; i++) SalvarPlayer(i); return 1; } public OnPlayerRequestClass(playerid, classid) { return 1; } public OnPlayerConnect(playerid) { new str[78], playernome[MAX_PLAYER_NAME]; new String[100]; GetPlayerName(playerid, playernome, sizeof(playernome)); format(str, sizeof(str), "%s (ID:%d) conectou-se ao servidor.", playernome, playerid); SendClientMessageToAll(-1, str); //REGISTRO LOGIN format(String, sizeof(String), "Contas/%s.ini", playernome); if(!dini_Exists(String)) { format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s {1E90FF}Nгo Registrado\n\n{FFFFFF} Digite Uma Senha Para Continuar", playernome); ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro", String, "Registrar", "Cancelar"); } else { format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar", playernome); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", String, "Logar", "Cancelar"); } return 1; } public OnPlayerDisconnect(playerid, reason) { new str[78], playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); format(str, sizeof(str), "%s (ID:%d) desconectou-se do servidor.", playernome, playerid); SendClientMessageToAll(-1, str); SalvarPlayer(playerid); return 1; } public OnPlayerDeath(playerid, killerid, reason) { if(IsPlayerConnected(killerid)) { Matou[killerid]++; } Morreu[playerid]++; return 1; } public OnPlayerSpawn(playerid) { SetPlayerPos(playerid, 1154.5298, -1758.9674, 13.6671); return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/status", cmdtext, true, ![]() { Status(playerid); return 1; } return 0; } public GanharExp() { foreach(Player, i) { new string[128], arq[148], playernome[MAX_PLAYER_NAME]; GetPlayerName(i, playernome, sizeof(playernome)); format(arq, sizeof(arq), "Contas/%s.ini", playernome); if(IsPlayerConnected(i)) { if(Exp[i] >= 4) { Level[i]++; Exp[i] = 0; format(string, sizeof(string), "(UP) Vocк acaba de ganhar +1 level, somando um total de %d", Level[i]); SendClientMessage(i, 0x00FF00AA, string); PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0); dini_IntSet(arq, "EXP", Exp[i]); dini_IntSet(arq, "Level", Level[i]); SetPlayerScore(i,Level[i]); } else { Exp[i]++; format(string, sizeof(string), "(EXP) Vocк acaba de ganhar +1 ponto de experiкncia (%d/5)", Exp[i]); SendClientMessage(i, 0x00FF00AA, string); PlayerPlaySound(i, 1057, 0.0, 0.0, 10.0); dini_IntSet(arq, "EXP", Exp[i]); } } } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == REGISTRO) { if(response) { if(!strlen(inputtext)) { new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[100]; format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s {1E90FF}Nгo Registrado\n\n{FFFFFF} Digite Uma Senha Para Continuar", playernome); ShowPlayerDialog(playerid, REGISTRO, DIALOG_STYLE_INPUT, "Registro", String, "Registrar", "Cancelar"); SendClientMessage(playerid,0x1E90FFAA,"Senha invalida, digite uma senha vбlida"); return 1; } new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[100]; format(String, sizeof(String), "Contas/%s.ini", playernome); dini_Create(String); dini_Set(String,"Senha",inputtext); dini_IntSet(String,"Dinheiro",0); dini_IntSet(String,"Vida", 100); dini_IntSet(String,"Colete", 100); dini_IntSet(String,"Matou",0); dini_IntSet(String,"Morreu",0); dini_IntSet(String,"Logou",0); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", "{1E90FF}Pronto vocк se registrou agora digite Sua Senha Para Logar-Se", "Logar", "Cancelar"); return 1; } else { SendClientMessage(playerid, 0xFF0000AA, "Vocк Foi Kickado Porque Nгo Quis Se Registrar!!"); Kick(playerid); return 1; } } if(dialogid == LOGIN) { if(response) { if(!strlen(inputtext)) { new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[100]; format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar", playernome); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", String, "Logar", "Cancelar"); SendClientMessage(playerid,0x1E90FFAA,"Senha Incorreta !"); return 1; } new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[100]; format(String, sizeof(String), "Contas/%s.ini", playernome); if(!strcmp(inputtext,dini_Get(String,"Senha"),fals e)) { SetarPlayer(playerid); Logou[playerid]++; SendClientMessage(playerid,0x00FF00AA,"Vocк Foi Logado Com Sucesso > Escolha Sua Skin!"); return 1; } else { SendClientMessage(playerid,0x00FF00AA,"Senha incorreta digite-a novamente"); format(String, sizeof(String), "{7FFFD4}Nick: {1E90FF}%s {1E90FF}Registrado\n\n{FFFFFF} Digite Sua Senha Para Logar", playernome); ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Registro", String, "Logar", "Cancelar"); } return 1; } else { SendClientMessage(playerid, 0xFF0000AA, "Vocк nгo quis se logar, por este motivo serб Kickado"); Kick(playerid); return 1; } } return 1; } SalvarPlayer(playerid) { new Float:Vida; new Float:Colete; GetPlayerHealth(playerid, Vida); GetPlayerArmour(playerid, Colete); new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[50]; format(String, sizeof(String), "Contas/%s.ini", playernome); dini_IntSet(String,"Dinheiro", GetPlayerMoney(playerid)); dini_FloatSet(String,"Vida", Vida); dini_FloatSet(String,"Colete", Colete); dini_IntSet(String,"Matou", Matou[playerid]); dini_IntSet(String,"Morreu", Morreu[playerid]); dini_IntSet(String,"Logou", Logou[playerid]); return 1; } SetarPlayer(playerid) { new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[50]; format(String, sizeof(String), "Contas/%s.ini", playernome); GivePlayerMoney(playerid, dini_Int(String,"Dinheiro")); SetPlayerHealth(playerid, dini_Int(String,"Vida")); SetPlayerArmour(playerid, dini_Int(String,"Colete")); Matou[playerid] = dini_Int(String, "Matou"); Morreu[playerid] = dini_Int(String, "Morreu"); Logou[playerid] = dini_Int(String, "Logou"); return 1; } Status(playerid) { new playernome[MAX_PLAYER_NAME]; GetPlayerName(playerid, playernome, sizeof(playernome)); new String[128]; SendClientMessage(playerid, 0xFF0000AA, "================================================" ); format(String, sizeof(String),"Status De %s",playernome); SendClientMessage(playerid, 0xFFFF00AA,String); format(String, sizeof(String),"Dinheiro: %d", GetPlayerMoney(playerid)); SendClientMessage(playerid, 0x1E90FFAA,String); format(String, sizeof(String),"Matou: %d",Matou[playerid]); SendClientMessage(playerid, 0x1E90FFAA,String); format(String, sizeof(String),"Morreu: %d",Morreu[playerid]); SendClientMessage(playerid, 0x1E90FFAA,String); format(String, sizeof(String),"Vocк Jб Logou %d Vezes Neste Servidor",Logou[playerid]); SendClientMessage(playerid, 0x1E90FFAA,String); SendClientMessage(playerid, 0xFF0000AA, "================================================" ); return 1; } |
D:\Users\Matheus\Desktop\BaseScript\gamemodes\base rp.pwn(112) : error 029: invalid expression, assumed zero D:\Users\Matheus\Desktop\BaseScript\gamemodes\base rp.pwn(112) : warning 215: expression has no effect D:\Users\Matheus\Desktop\BaseScript\gamemodes\base rp.pwn(112) : error 001: expected token: ";", but found ")" D:\Users\Matheus\Desktop\BaseScript\gamemodes\base rp.pwn(112) : error 029: invalid expression, assumed zero D:\Users\Matheus\Desktop\BaseScript\gamemodes\base rp.pwn(112) : fatal error 107: too many error messages on one line |
new Matou[MAX_PLAYERS];
new Morreu[MAX_PLAYERS];
new Logou[MAX_PLAYERS];
new Exp[MAX_PLAYERS];
new Level[MAX_PLAYERS];
poderia usar uma enum para realizar uma otimizaзгo!
//exemplo
enum player {
Level,
Matou,
Morreu,
Xp
};
new PlayerData[MAX_PLAYERS][player];
//coisas como
new playernome[MAX_PLAYER_NAME];
GetPlayerName(playerid, playernome, sizeof(playernome));
poderiam ser mais otimizadas usando uma stock ..
Ok, vamos aos motivos do seu projeto ser ruim:
~ Usando Dini em pleno 2015 sйrio? ~ Multiplas arrays para o player, por que nгo usar uma Enum? ~ Poderia ter utilizado uma funзгo para pegar a pasta do player. ~ O valor do MAX_PLAYERS pode ser modificado para melhor otimizaзгo. ~ Se vocк tinha a include "foreach" porque usou loop "for" no OnGameModeExit ?? ~ Melhora essa identaзгo, porque o cуdigo muito difнcil de ler. OBS: Tudo que citei, nгo й para lhe ofender ao algo assim, й para ajuda-lo a melhorar. |
#include <dini>
Obrigado pelas dicas, sou iniciante no ramo, pretendo melhorar, vou estudar mais talvez eu nem poste mais aqui por um tempo para nгo ser zuado.
|