26.02.2011, 22:26
pawn Код:
#include <a_samp>
#include <dini>
#include <dudb>
#include <utils>
enum ipl
{
administrador,
sexo
}
new arquivo[2*100];
new nome[MAX_PLAYER_NAME];
new informacoes[MAX_PLAYERS][ipl];
new bool: logado[MAX_PLAYERS], bool: iniciante[MAX_PLAYERS], bool: checkpoint[MAX_PLAYERS];
new Float: x[MAX_PLAYERS], Float: y[MAX_PLAYERS], Float: z[MAX_PLAYERS], Float: angulo[MAX_PLAYERS];
main()
{
print("\nServidor conectado\n");
}
public OnGameModeInit()
{
UsePlayerPedAnims();
SetGameModeText("Bsc");
AddPlayerClass(0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
AddStaticVehicle(462, 1562.51904297, -2338.48339844, 13.21709442, 90.00000000, -1, 1);
AddStaticVehicle(462, 1562.44750977, -2334.94116211, 13.21709442, 90.00000000, -1, -1);
AddStaticVehicle(462, 1562.40856934, -2331.87475586, 13.22153664, 90.00000000, -1, -1);
AddStaticVehicle(462, 1562.53649902, -2328.61914062, 13.22187996, 90.00000000, 6, 1);
AddStaticVehicle(462, 1562.54785156, -2325.38549805, 13.22191048, 90.00000000, 3, 1);
AddStaticVehicle(462, 1562.53295898, -2322.26831055, 13.22187042, 90.00000000, -1, -1);
AddStaticVehicle(462, 1562.58117676, -2318.79101562, 13.22200012, 90.00000000, -1, -1);
return 1;
}
public OnGameModeExit()
{
print("\nServidor desconectado\n");
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, nome, sizeof nome);
format(arquivo, sizeof arquivo, "contas/%s.ini", nome);
if (!fexist(arquivo) )
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Registro", "{FFFFFF}Bem vindo.\nPor favor digite uma senha:", "Registrar-me", "");
}
if (fexist(arquivo) )
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFFFF}Login", "{FFFFFF}Por favor digite sua senha:", "Logar-me", "");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerName(playerid, nome, sizeof nome);
format(arquivo, sizeof arquivo, "contas/%s.ini", nome);
if (fexist(arquivo) )
{
GetPlayerPos(playerid, x[playerid], y[playerid], z[playerid]);
GetPlayerFacingAngle(playerid, angulo[playerid]);
dini_IntSet(arquivo, "Dinheiro", GetPlayerMoney(playerid) );
dini_IntSet(arquivo, "Level", GetPlayerScore(playerid) );
dini_IntSet(arquivo, "Level procurado", GetPlayerWantedLevel(playerid) );
dini_IntSet(arquivo, "Level administrativo", informacoes[playerid][administrador]);
dini_IntSet(arquivo, "Pele", GetPlayerSkin(playerid) );
dini_FloatSet(arquivo, "X", x[playerid]);
dini_FloatSet(arquivo, "Y", y[playerid]);
dini_FloatSet(arquivo, "Z", z[playerid]);
dini_FloatSet(arquivo, "Вngulo", angulo[playerid]);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
format(arquivo, sizeof arquivo, "contas/%s.ini", nome);
if (logado[playerid] == false)
{
Kick(playerid);
return 1;
}
if (iniciante[playerid] == true)
{
if (informacoes[playerid][sexo] == 1)
{
SetPlayerSkin(playerid, 60);
}
if (informacoes[playerid][sexo] == 2)
{
SetPlayerSkin(playerid, 56);
}
SetPlayerPos(playerid, 1612.4882, -2329.4709, 13.5469);
SetPlayerFacingAngle(playerid, 358.4933);
SendClientMessage(playerid, 0xAAC800AA, "Vocк chegou da viajem.");
SetPlayerCheckpoint(playerid, 1562.51904297, -2338.48339844, 13.21709442, 1.0);
checkpoint[playerid] = true;
iniciante[playerid] = false;
return 1;
}
x[playerid] = dini_Float(arquivo, "X");
y[playerid] = dini_Float(arquivo, "Y");
z[playerid] = dini_Float(arquivo, "Z");
angulo[playerid] = dini_Float(arquivo, "Вngulo");
SetPlayerPos(playerid, x[playerid], y[playerid], z[playerid]);
SetPlayerFacingAngle(playerid, angulo[playerid]);
SetPlayerSkin(playerid, dini_Int(arquivo, "Pele") );
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 OnPlayerCommandText(playerid, cmdtext[])
{
new idx, cmd[500], texto[500];
cmd = strtok(cmdtext, idx);
if (strcmp("/gps", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{FFFFFF}Gps", "{FFFFFF}Lugares do governo", "Selecionar", "Cancelar");
return 1;
}
if (strcmp(cmd, "/daradmin", true) == 0)
{
GetPlayerName(playerid, nome, sizeof nome);
if (strcmp(nome, "Jose_Freire", true) == 0)
{
new id, tmp[500];
tmp = strtok(cmdtext, idx);
if (!strlen(tmp) )
{
SendClientMessage(playerid, 0xFF9E50AA, "Use: /daradmin id level.");
return 1;
}
id = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
new level = strval(tmp);
if (id != INVALID_PLAYER_ID)
{
informacoes[playerid][administrador] = level;
}
if(id == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Este jogador nгo estб conectado.");
}
}
if (informacoes[playerid][administrador] < 5)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Vocк nгo й o criador do servidor.");
}
return 1;
}
if (strcmp(cmdtext, "/admins", true) == 0)
{
SendClientMessage(playerid, 0xFFFFFFFF, " Administradores ");
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if (logado[playerid] == true)
{
GetPlayerName(i, nome, sizeof nome);
if (informacoes[i][administrador] == 1)
{
format(texto, sizeof texto, "| %s | - Colaborador.");
SendClientMessage(playerid, 0x503C00AA, texto);
}
if (informacoes[i][administrador] == 2)
{
format(texto, sizeof texto, "| %s | - Moderador.");
SendClientMessage(playerid, 0x004C60AA, texto);
}
if (informacoes[i][administrador] == 3)
{
format(texto, sizeof texto, "| %s | - Organizador.");
SendClientMessage(playerid, 0x0F6800AA, texto);
}
if (informacoes[i][administrador] == 4)
{
format(texto, sizeof texto, "| %s | - Administrador.");
SendClientMessage(playerid, 0x0020D8AA, texto);
}
if (informacoes[i][administrador] == 5)
{
format(texto, sizeof texto, "| %s | - Dono do servidor.");
SendClientMessage(playerid, 0xE85C00AA, texto);
}
}
}
return 1;
}
if (strcmp("/gmx", cmdtext, true, 10) == 0)
{
if (informacoes[playerid][administrador] == 5)
{
SendRconCommand("gmx");
}
if (informacoes[playerid][administrador] < 5)
{
SendClientMessage(playerid, 0xFFFFFFFF, "Vocк nгo й o dono do servidor.");
}
return 1;
}
return SendClientMessage(playerid, 0xFFFFFFFF, "Comando inexistente.");
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if (checkpoint[playerid] == true)
{
DisablePlayerCheckpoint(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[])
{
GetPlayerName(playerid, nome, sizeof nome);
format(arquivo, sizeof arquivo, "contas/%s.ini", nome);
if (dialogid == 1)
{
if (response)
{
if (strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Registro", "{FFFFFF}Por favor digite algo:", "Registrar-me", "");
return 0;
}
if (!fexist(arquivo) )
{
dini_Create(arquivo);
dini_IntSet(arquivo, "Senha", udb_hash(inputtext) );
ShowPlayerDialog(playerid, 3, DIALOG_STYLE_MSGBOX, "{FFFFFF}Sexo", "{FFFFFF}Selecione o seu sexo.", "Masculino", "Feminino");
}
}
}
if (dialogid == 2)
{
if (response)
{
if (strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFFFF}Login", "{FFFFFF}Por favor digite algo:", "Logar-me", "");
return 0;
}
if (fexist(arquivo) )
{
new senha = dini_Int(arquivo, "Senha");
if (udb_hash(inputtext) != senha)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFFFF}Login", "{FFFFFF}Por favor digite a senha correta:", "Logar-me", "");
return 1;
}
if (udb_hash(inputtext) == senha)
{
SendClientMessage(playerid, 0xE80B00AA, "Por motivos de seguranзa clique em spawn.");
SetPlayerMoney(playerid, dini_Int(arquivo, "Dinheiro") );
SetPlayerScore(playerid, dini_Int(arquivo, "Level") );
SetPlayerWantedLevel(playerid, dini_Int(arquivo, "Level procurado") );
informacoes[playerid][administrador] = dini_Int(arquivo, "Level administrativo");
logado[playerid] = true;
return 1;
}
}
}
}
if (dialogid == 3)
{
if (response)
{
informacoes[playerid][sexo] = 1;
iniciante[playerid] = true;
logado[playerid] = true;
SpawnPlayer(playerid);
SetSpawnInfo(playerid, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
}
else
{
informacoes[playerid][sexo] = 2;
iniciante[playerid] = true;
logado[playerid] = true;
SpawnPlayer(playerid);
SetSpawnInfo(playerid, 0, 0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0);
}
}
if (dialogid == 4)
{
if (response)
{
ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "{FFFFFF}Gps - lugares governamentais", "{FFFFFF}Estacionamento pъblico", "Selecionar", "Voltar");
}
else
{
SendClientMessage(playerid, 0x50FFFFAA, "Vocк cancelou.");
}
}
if (dialogid == 5)
{
if (response)
{
SetPlayerCheckpoint(playerid, 1562.51904297, -2338.48339844, 13.21709442, 1.0);
checkpoint[playerid] = true;
}
else
{
ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "{FFFFFF}Gps", "{FFFFFF}Lugares do governo", "Selecionar", "Cancelar");
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}