public OnPlayerText(playerid, text[]) { if(SPAM_PLAYERID(text)) { printf("DEBUG: SPAM_PLAYERID(const VOLUE[]) chamada com sucesso!"); /* O debug mostrar se a Callback estб funcionando corretamente, e verifica se foi chamada na hora da divulgaзгo */ /* Aqui vocк pode acrescentar mensagem do tipo global, ou nгo global. Caso nгo queira por nenhuma mensagem, apenas ignore */ Kick(playerid); /* Funзгo que leva o player ser kikado do servidor, caso queira efetuar o banimento, utilize a callback do seu sistema, ou efetueo banimento por client-server "Ban(playerid); " */ return false; /* A funзгo Anti-SPAM retornara sempre falsa, e tambйm irб verificar a Callback SPAM_PLAYERID(const VOLUE[]) se foi chamada dentro dos params, mantenham o retorno sempre falso nesta opзгo */ } retun false; /* Retorno falso para a Callback OnPlayerText e outros script, nгo й necessбrio alterar o mesmo */ }
SPAM_PLAYERID(const VOLUE[]) { new SPAM_DIGITS, VOLUE_DIGITS ; for(new PARAMS_DIGIT, PARAMS_DIGITS, PLAYERIP[16], LEN = strlen(VOLUE); PARAMS_DIGIT < LEN; PARAMS_DIGIT ++) { if('0' <= VOLUE[PARAMS_DIGIT] <= '9') { PARAMS_DIGITS = PARAMS_DIGIT + 1; while('0' <= VOLUE[PARAMS_DIGITS] <= '9') PARAMS_DIGITS ++; strmid(PLAYERIP, VOLUE, PARAMS_DIGIT, PARAMS_DIGITS); if(0 <= strval(PLAYERIP) <= 255) SPAM_DIGITS ++; PARAMS_DIGIT = PARAMS_DIGITS - 1; else if(SPAM_DIGITS >= 1) VOLUE_DIGITS ++; SPAM_DIGITS = 0; } } if(SPAM_DIGITS >= 1) VOLUE_DIGITS ++; if(VOLUE_DIGITS >= 4) return true; return false; }
/* Chaves Veнculos */
#include <a_samp>
#include <ZCMD>
#include <sscanf2>
enum pInfo
{
KeyProfissao,
}
new PlayerData[MAX_PLAYERS][pInfo];
CMD:pegarchaves(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 0.0, 0.0, 0.0)) return 1; // Estб no lugar de pegar as chaves
new vehicleid;
if(sscanf(params, "d", vehicleid))
return SendClientMessage(playerid, -1, "Uso: /pegarchaves [vehicleid] - veja o id do veiculo no /dl");
if(vehicleid < 1 || vehicleid > MAX_VEHICLES)
return SendClientMessage(playerid, -1, "Valor de Chave invбlido.");
if(ChaveEmUso(vehicleid))
return SendClientMessage(playerid, -1, "Essa chave jб estб sendo usado por outra pessoa.");
new Float:cPos[3];
GetVehiclePos(vehicleid, cPos[0], cPos[1], cPos[2]);
if(cPos[0] == 0.000)
return SendClientMessage(playerid, -1, "Esse veнculo nгo existe.");
PlayerData[playerid][KeyProfissao] = vehicleid;
SendClientMessage(playerid, -1, "Vocк pegou a chave desse carro/caminhгo.");
return 1;
}
CMD:deixarchave(playerid)
{
if(PlayerData[playerid][KeyProfissao] == 0)
return SendClientMessage(playerid, -1, "Vocк nгo tem nenhuma chave nas mгos!");
PlayerData[playerid][KeyProfissao] = 0;
SendClientMessage(playerid, -1, "Vocк deixou as chaves do veнculo aqui.");
return 1;
}
CMD:motor(playerid)
{
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, -1, "Vocк nгo estб em um veнculo para ligar o motor.");
new vehicleid = GetPlayerVehicleID(playerid);
if(PlayerData[playerid][KeyProfissao] == vehicleid)
{
// Liberado para digirir.");
}
else SendClientMessage(playerid, -1, "Vocк nгo tem as chaves desse veнculo.");
return 1;
}
CMD:darchave(playerid, params[])
{
new
id, chave;
if(sscanf(params, "ud", id, chave))
return SendClientMessage(playerid, -1, "Digite: /darchave [id player] [chave id]");
if(PlayerData[playerid][KeyProfissao] == 0)
return SendClientMessage(playerid, -1, "Vocк nгo tem uma chave para dar para esse jogador.");
if(PlayerData[id][KeyProfissao] > 0)
return SendClientMessage(playerid, -1, "Esse jogador jб tem uma chave.");
SendClientMessage(playerid, -1, "Vocк deu a sua chave para esse jogador.");
SendClientMessage(id, -1, "Um jogador te deu uma chave de um carro.");
PlayerData[id][KeyProfissao] = PlayerData[playerid][KeyProfissao];
PlayerData[playerid][KeyProfissao] = 0;
return 1;
}
CMD:abrircarro(playerid) // Comando para abrir o carro, para abrir as portas, й claro.
{
if(PlayerData[playerid][KeyProfissao] == 0)
return SendClientMessage(playerid, -1, "Vocк nгo tem a chave de um carro para abrir o mesmo.");
if(IsPlayerNearTheVehicle(playerid, PlayerData[playerid][KeyProfissao]))
{
SendClientMessage(playerid, -1, "Seu carro foi aberto.");
//Cуdigo abaixo
}
else SendClientMessage(playerid, -1, "Vocк nгo estб perto do seu carro.");
return 1;
}
CMD:comandos(playerid)
{
SendClientMessage(playerid, -1, "/pegarchaves [veiculoid] • /deixarchave • /motor • /darchave [playerid] [chaveid]");
return 1;
}
stock IsPlayerNearTheVehicle(playerid, vehicleid, Float: Radius = 3.0)
{
new Float:vPos[3];
GetVehiclePos(vehicleid, vPos[0], vPos[1], vPos[2]);
if(IsPlayerInRangeOfPoint(playerid, Radius, vPos[0], vPos[1], vPos[2])) return true;
else return false;
}
stock ChaveEmUso(chaveid)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerData[i][KeyProfissao] == chaveid) return true;
else return false;
}
}
return -1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerData[playerid][KeyProfissao] = 0;
return 1;
}
// Em seu sistema de salvamento, adcione: pVida, pColete
// Em OnPlayerSpawn ou no seu sistema de carregamento de dados adcione:
SetPlayerHealth(playerid, PlayerDados[playerid][pVida]);
SetPlayerArmour(playerid, PlayerDados[playerid][pColete]);
// E vamos ao cуdigo!
CMD:setarvida(playerid, params[]) {
new String[128], IdPlayer, Vida;
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "ud", IdPlayer, Vida)) return SendClientMessage(playerid, 0x00FFFFAA, "[Comando]{CFCFCF} Use: /SetarVida [IdPlayer][Vida]");
if(!IsPlayerConected(IdPlayer)) {
SetPlayerHealth(IdPlayer, Vida);
format(String, sizeof(String), "O(a) staff:{FF0000} %s{CFCFCF} setou sua vida!", -VARIAVEL DE PEGAR NOME-);
SendClientMessage(IdPlayer, 0xCFCFCFAA, String);
}
return 1;
}
CMD:setarcolete(playerid, params[]) {
new String2[128], IdPlayer2, Colete;
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "ud", IdPlayer2, Colete)) return SendClientMessage(playerid, 0x00FFFFAA, "[Comando]{CFCFCF} Use: /SetarColete [IdPlayer][Colete]");
if(!IsPlayerConected(IdPlayer2)) {
SetPlayerArmour(IdPlayer2, Colete);
format(String2, sizeof(String2), "O(a) staff:{FF0000} %s{CFCFCF} setou seu colete!", -VARIAVEL DE PEGAR NOME-);
SendClientMessage(IdPlayer2, 0xCFCFCFAA, String);
}
return 1;
}
PHP Code:
|
// topo gm
new SoundTimer[MAX_PLAYERS];
CMD:teste(playerid){
/*
playerid,
1165: soundid,
1166: soundstop,
15: quantidade de vezes que serб repitido o som,
3: tempo que o som serб chamado novamente, vocк capta isso ouvindo e ve quanto tempo demora pra acabar.
*/
PlaySoundLoop(playerid, 1165, 1166, 15, 3);
return 1;
}
/*
tempo = 1: padrгo pra sempre 1s
loop = 1: padrгo para loop ficar rodando para sempre.
*/
PlaySoundLoop(playerid, soundid, soundidstop, quantidade, tempo = 1, loop = 1){
SoundTimer[playerid] = SetTimerEx("PlaySoundPlayer", 1000*tempo, loop, "dddd", playerid, soundid, soundidstop, quantidade);
return 1;
}
forward PlaySoundPlayer(playerid, soundid, soundidstop, quantidade, parar);
public PlaySoundPlayer(playerid, soundid, soundidstop, quantidade, parar){
PlayerPlaySound(playerid, soundid, 0.0, 0.0, 0.0);
if(++parar > quantidade){
parar = 0;
// debugs
printf("%d - %d - %d - %d - %d", playerid, soundid, soundidstop, quantidade, parar);
PlayerPlaySound(playerid, soundidstop, 0.0, 0.0, 0.0);
KillTimer(SoundTimer[playerid]);
}
// debugs
printf("%d/%d", parar, quantidade);
return 1;
}
function CriarChaves(casaid)
{
/*
This function will create the house key.
Paramters:
casaid - From Iterator:House
*/
new FileChaves[50];
format(FileChaves, sizeof(FileChaves), PASTA_CHAVESCASAS, InfoCasa[casaid][ID]);
dini_Create(FileChaves);
// ------------------------------------------------------------------------------- //
new aString[MAX_NAME_PLAYER];
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
format(ChavesCasas[casaid][i], MAX_NAME_PLAYER, "Ninguem");
format(aString, sizeof(aString), "Chave%d", i);
dini_Set(FileChaves, aString, "Ninguem");
}
}
// ----------------------------------------------------------------------------------------------------------------------------------- //
function InserirChaveCasa(playerid, casaid)
{
/*
This function will enter a home key for a player.
Paramters:
playerid - The player
casaid - From Iterator:House
*/
new FileChaves[50];
format(FileChaves, sizeof(FileChaves), PASTA_CHAVESCASAS, InfoCasa[casaid][ID]);
// ------------------------------------------------------------------------------- //
new aString[MAX_NAME_PLAYER];
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
if(!strcmp(ChavesCasas[casaid][i], "Ninguem", false))
{
format(aString, sizeof(aString), "Chave%d", i);
dini_Set(FileChaves, aString, pNome(playerid));
return i;
}
}
return -1;
}
// ----------------------------------------------------------------------------------------------------------------------------------- //
function ContarChavesPlayer(playerid, casaid)
{
/*
This function will return how many keys a player has
from a certain house.
Paramters:
playerid - The Player
casaid - The house ID
*/
new Contar;
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
if(!strcmp(ChavesCasas[casaid][i], pNome(playerid), false))
{
Contar ++;
}
}
return Contar;
}
// ----------------------------------------------------------------------------------------------------------------------------------- //
function CarregarChavesCasas()
{
/*
This function will load all keys of a given house.
Paramters:
no Paramters
*/
new FileChaves[50], aString[50];
foreach(new c : House)
{
format(FileChaves, sizeof(FileChaves), PASTA_CHAVESCASAS, InfoCasa[c][ID]);
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
format(ChavesCasas[c][i], MAX_NAME_PLAYER, "Ninguem");
// ------------------------------------------------------------ //
format(aString, sizeof(aString), "Chave%d", i);
if(strcmp(dini_Get(FileChaves, aString), "Ninguem", false))
{
format(ChavesCasas[c][i], MAX_NAME_PLAYER, dini_Get(FileChaves, aString));
}
}
}
}
// ----------------------------------------------------------------------------------------------------------------------------------- //
function SalvarCasasChaves(casaid)
{
/*
This function will save all keys of a particular house.
Paramters:
casaid - The House ID
*/
new FileChaves[50], aString[15];
format(FileChaves, sizeof(FileChaves), PASTA_CHAVESCASAS, InfoCasa[casaid][ID]);
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
if(strcmp(ChavesCasas[casaid][i], "Ninguem", false))
{
format(aString, sizeof(aString), "Chave%d", i);
dini_Set(FileChaves, aString, ChavesCasas[casaid][i]);
}
}
}
// ----------------------------------------------------------------------------------------------------------------------------------- //
function DarChaves(playerid, id, casaid)
{
/*
This function will hand one of your keys to a
house to another player.
Paramters:
playerid - The Player ID
id - The player receiving the key
casaid - The Casa ID
*/
for(new i = 0; i < MAX_CHAVES_POR_CASA; ++ i)
{
if(!strcmp(ChavesCasas[casaid][i], pNome(playerid), false))
{
format(ChavesCasas[casaid][i], pNome(id));
return i;
}
}
// ------------------------------------------------------------------------------- //
SCMEx(playerid, 0xFF8D1CFF, "[ Chaves ]: Vocк deu uma chave da Casa ID: %d para o(a) jogador(a) %s.", casaid, pNome(id));
SCMEx(id, 0xFF8D1CFF, "[ Chaves ]: Vocк recebeu uma chave da Casa ID: %d do(a) jogador(a) %s.", casaid, pNome(playerid));
SalvarCasasChaves(casaid);
}
//Par ou нmpar?
#include a_samp
main () {}
new numberChosen = 120;
stock evenOrOdd(number) {
number = number % 2;
if(number == 0)
print("Par");
else
print("Нmpar");
return 1;
}
public OnGameModeInit() {
evenOrOdd(numberChosen);
return 1;
}
//Listando nъmeros pares e нmpares atй uma quantidade.
#include a_samp
main () {}
new numberChosen = 10;
public OnGameModeInit() {
new contNumber = 0, number;
while(contNumber < numberChosen) {
contNumber++;
number = contNumber % 2;
if(number == 0) printf("%d й par.", contNumber);
else printf("%d й нmpar.", contNumber);
}
return 1;
}
//Listando nъmeros pares
#include a_samp
main () {}
new numberChosen = 10;
public OnGameModeInit() {
new contNumber = 0, number;
while(contNumber < numberChosen) {
contNumber++;
number = contNumber % 2;
if(number == 0) printf("%d й par.", contNumber);
}
return 1;
}
//Listando nъmeros нmpares
#include a_samp
main () {}
new numberChosen = 10;
public OnGameModeInit() {
new contNumber = 0, number;
while(contNumber < numberChosen) {
contNumber++;
number = contNumber % 2;
if(number != 0) printf("%d й нmpar.", contNumber);
}
return 1;
}
const BULLET_SYNC = 206;
OPacket:BULLET_SYNC(playerid, BitStream:bs)
{
if(GetPlayerTeam(playerid) != NO_TEAM && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
static from, hittype, hitid;
BS_IgnoreBits(bs, 8);
BS_ReadValue(
bs,
PR_UINT16, from,
PR_UINT8, hittype,
PR_UINT16, hitid
);
//BS_SetReadOffset(bs, 0); //se houver outra filtragem do mesmo pacote
if(hittype == BULLET_HIT_TYPE_VEHICLE && hitid == GetPlayerVehicleID(playerid))
{
if(GetPlayerTeam(playerid) == GetPlayerTeam(from))
{
return 0;
}
}
}
return 1;
}
p_Log("Open Server", "O servidor foi iniciado!"); new v_Player[4] = "N/A"; p_Log("Open Server", v_Player); public OnGameModeInit() { p_Log("Open Server", "O servidor foi iniciado!"); return true; }
enum DATA_TIMER { t_Day, t_Year, t_Month, t_Second, t_Minute, t_Hour, } new s_Timer[DATA_TIMER];
stock p_Log(f_Log[], const catch[]) { new File: p_File, p_Path[256] ; getdate(s_Timer[t_Year], s_Timer[t_Month], s_Timer[t_Day]); gettime(s_Timer[t_Hour], s_Timer[t_Minute], s_Timer[t_Second]); format(p_Path, 256, "logs_server/%s.sys", f_Log); p_File = fopen(p_Path, io_append); format(String, 256, "< %02d/%02d/%d | %02d:%02d:%02d > %s\r\n", s_Timer[t_Day], s_Timer[t_Month], s_Timer[t_Year], s_Timer[t_Hour], s_Timer[t_Minute], s_Timer[t_Second], catch); fwrite(p_File, String), fclose(p_File); return true; }
ґ LOG DE DADOS
Estou disponibilizando este Cуdigo Ъtil para aqueles que desejam monitorar Commands/Systems. Porйm o intuito deste cуdigo, й ajuda a identificar falhas em sistemas e problemas operacionais.. Tanto quanto pode salvar informaзхes geradas por usuбrios do seu servidor! ґ Utilizando da seguinte forma como exemplo: Code:
p_Log("Open Server", "O servidor foi iniciado!"); new v_Player[4] = "N/A"; p_Log("Open Server", v_Player); public OnGameModeInit() { p_Log("Open Server", "O servidor foi iniciado!"); return true; } ґ Resultados: ![]() ![]() ![]() ґ Caso use o Cуdigo Ъtil LEMBRE-SE de criar a seguinte pasta logs_server em scriptfiles localizado em seu gamemode.. Code:
enum DATA_TIMER { t_Day, t_Year, t_Month, t_Second, t_Minute, t_Hour, } new s_Timer[DATA_TIMER]; Code:
stock p_Log(f_Log[], const catch[]) { new File: p_File, p_Path[256] ; getdate(s_Timer[t_Year], s_Timer[t_Month], s_Timer[t_Day]); gettime(s_Timer[t_Hour], s_Timer[t_Minute], s_Timer[t_Second]); format(p_Path, 256, "logs_server/%s.sys", f_Log); p_File = fopen(p_Path, io_append); format(String, 256, "< %02d/%02d/%d | %02d:%02d:%02d > %s\r\n", s_Timer[t_Day], s_Timer[t_Month], s_Timer[t_Year], s_Timer[t_Hour], s_Timer[t_Minute], s_Timer[t_Second], catch); fwrite(p_File, String), fclose(p_File); return true; } - Invasгo de Bases, - Raio de proximidade, - Spawn e Setagens. |
Par ou нmpar?
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
Cуdigo By: Eu / Henrique Calenzo ( Se me mostrarem que nгo й ъtil eu removo ).Este cуdigo eu uso para que o player nгo logue com a mesma conta duas ou mais vezes, evitando assim o bug de duplicar, triplicar,... os dados da conta. Variбveis: Armazena o que o player digitou no login pawn Code:
pawn Code:
pawn Code:
pawn Code:
pawn Code:
|
Impede nгo. Jб vi muita gente bugando dinheiro por causa disso.
|
Ele bloqueia sу pra quem usa o nick no Launcher do sa-mp, mas e pros servidores que usam tela de login em TextDraws( Pedindo nome e senha... ) ? ai que ocorre o bug.
|
Amigo, se vocк entrar com um nickname que jб estб logado, o prуprio SA-MP impede o login. Ou seja, o cуdigo acaba sendo desnecessбrio.
|
O prуprio SA-MP bloqueia, sim.
Aparece aquele erro de nickname inaceitбvel (A-Z / 0-9) e bloqueia o acesso imediatamente atй a saнda do jogador com o mesmo nome. |
Respondendo:
Nгo impede o login. Por que? porque o player loga no launcher do sa-mp com nicks diferentes. mas na tela de login й usado SetPlayerName e dai o player resolve entrar com a mesma conta, assim duplicando os dados. |
1 The name was changed successfully 0 The name is already in use (including by this player at the moment) or the player specified is not connected -1 The name can not be changed (too long or has invalid characters)
#include a_samp
#include zcmd
#define MAX_ATM 2
new Text3D:TexATM[MAX_ATM];
enum infoatm
{
cID,
Float:cPosX,
Float:cPosY,
Float:cPosZ,
Float:cPosA,
cMax,
cInt
}
new CaixaInfo[MAX_ATM][infoatm] = {
{19324, 1507.66602, -1755.56201, 13.13839, 180.96274, 25000, 1},
{19324, 1507.66602, -1755.56201, 13.13839, 180.96274, 25000, 1}
};
public OnGameModeInit()
{
static atm;
do {
CreateDynamicObject(CaixaInfo[atm][cID], CaixaInfo[atm][cPosX],CaixaInfo[atm][cPosY],CaixaInfo[atm][cPosZ], 0.00000, 0.00000,CaixaInfo[atm][cPosA]);
TexATM[atm] = Create3DTextLabel(" >> ATM << \n" , -1,CaixaInfo[atm][cPosX],CaixaInfo[atm][cPosY],CaixaInfo[atm][cPosZ], 10.0, 0, 0);
atm++;
}
while(atm < MAX_ATM);
return 1;
}
public OnGameModeExit()
{
return 1;
}
command(atm, playerid, params[])
{
static atm , var[100];
do {
if(IsPlayerInRangeOfPoint(playerid, 1.0, CaixaInfo[atm][cPosX],CaixaInfo[atm][cPosY],CaixaInfo[atm][cPosZ]))
{
format(var, sizeof(var), "O Caixa Possui R$ %i de dinheiro disponivel para transferencia.",CaixaInfo[atm][cMax]);
SendClientMessage(playerid, -1, var);
}
atm++;
}
while(atm < MAX_ATM);
return 1;
}
CMD:recuperarv(playerid){ if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Vocк nгo tem permissгo para usar este comando!"); SetPlayerHealth(playerid, 100); SetPlayerArmour(playerid, 100); SendClientMessage(playerid, -1,"Vocк recuperou sua vida e colete com sucesso!"); return 1;}