SA-MP Forums Archive
[Ajuda] Usar esse comando 1x no mesmo id - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Usar esse comando 1x no mesmo id (/showthread.php?tid=606380)



Usar esse comando 1x no mesmo id - RianRBS - 03.05.2016

Olб galera sйra que vocкs podem me dar uma pequena ajuda? eu queria que esse comando abaixo fosse utilizado 1x sу no mesmo id tipo o Polнcial digitar /multar 0 dae o cara recebe a multa sй o Polнcial digtar o comando no mesmo ID da erro, eu nгo sei fazer isso entгo estуu pedindo ajuda pra vocКs ^^

Comandos abaixo !!



Код:
if(strcmp(cmd, "/multar", true) == 0) {
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
if(dini_Int(file, "Profissao") == Policial_C || dini_Int(file, "Profissao") == Policial_F || dini_Int(file, "Profissao") == Delegado || dini_Int(file, "Profissao") == Bope || dini_Int(file, "Profissao") == Swat || dini_Int(file, "Profissao") == Narcoticos || dini_Int(file, "Profissao") == Policial_M || dini_Int(file, "Profissao") == FBI || dini_Int(file, "Profissao") == Interpol || dini_Int(file, "Profissao") == LSPD || dini_Int(file, "aAdmin") == 1 || IsPlayerAdmin(playerid)){
new tmp[256];
new plid;
new quant;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
return 1;
}
plid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
return 1;
}
quant = strval(tmp);
if(quant > 1000 || quant <= 0){
SendClientMessage(playerid, Vermelho, "(INFO) Vocк nгo estб multando de forma justa.");
return 1;
}
if(IsPlayerConnected(plid)){
new pname[MAX_PLAYER_NAME];
GetPlayerName(plid, pname, MAX_PLAYER_NAME);
format(file2, sizeof(file2), PASTA_CONTAS, pname);
format(string, sizeof(string), "(INFO) Vocк recebeu uma multa de R$%d Pelo policial %s . O dinheiro foi retirado do banco.", quant, aname);
SendClientMessage(plid, COLOR_GREEN, string);
SendClientMessage(playerid, COLOR_GREEN, "(INFO) Multa dada.");
dini_IntSet(file2, "SaldoBancario", dini_Int(file2, "SaldoBancario")- quant);
return 1;
}
else{
SendClientMessage(playerid, Vermelho, "(INFO) O jogador nгo estб conectado!");
return 1;
}
}
}



Re: Usar esse comando 1x no mesmo id - F1N4L - 03.05.2016

Код:
new bool:UsouID[MAX_PLAYERS];

if(strcmp(cmd, "/multar", true) == 0) 
{
	new aname[MAX_PLAYER_NAME];
	
	GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
	
	format(file, sizeof(file), PASTA_CONTAS, aname);
	
	if(dini_Int(file, "Profissao") == Policial_C || dini_Int(file, "Profissao") == Policial_F || dini_Int(file, "Profissao") == Delegado || dini_Int(file, "Profissao") == Bope || dini_Int(file, "Profissao") == Swat || dini_Int(file, "Profissao") == Narcoticos || dini_Int(file, "Profissao") == Policial_M || dini_Int(file, "Profissao") == FBI || dini_Int(file, "Profissao") == Interpol || dini_Int(file, "Profissao") == LSPD || dini_Int(file, "aAdmin") == 1 || IsPlayerAdmin(playerid))
	{
		new tmp[256];
		new plid;
		
		new quant;
		
		tmp = strtok(cmdtext, idx);
		
		if(!strlen(tmp)) 
		{
			SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
			return 1;
		}
		
		plid = strval(tmp);
		
		tmp = strtok(cmdtext, idx);
		
		if(!strlen(tmp)) 
		{
			SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
			return 1;
		}
		
		if(UsouID[plid] == true) return SendClientMessage(playerid, Vermelho, "Esse ID jб foi utilizado!");
		
		quant = strval(tmp);
		
		if(quant > 1000 || quant <= 0)
		{
			SendClientMessage(playerid, Vermelho, "(INFO) Vocк nгo estб multando de forma justa.");
			return 1;
		}
		
		if(IsPlayerConnected(plid))
		{
			new pname[MAX_PLAYER_NAME];
			
			GetPlayerName(plid, pname, MAX_PLAYER_NAME);
			
			format(file2, sizeof(file2), PASTA_CONTAS, pname);
			
			format(string, sizeof(string), "(INFO) Vocк recebeu uma multa de R$%d Pelo policial %s . O dinheiro foi retirado do banco.", quant, aname);
			SendClientMessage(plid, COLOR_GREEN, string);
			
			SendClientMessage(playerid, COLOR_GREEN, "(INFO) Multa dada.");
			
			UsouID[plid] = true;
			
			dini_IntSet(file2, "SaldoBancario", dini_Int(file2, "SaldoBancario")- quant);
			return 1;
		}
		else
		{
			SendClientMessage(playerid, Vermelho, "(INFO) O jogador nгo estб conectado!");
			return 1;
		}
	}
}
Desculpa pela minha organizaзгo, eu acho mais fбcil assim pra mim

@EDIT

PS: Lembre-se de usar algum comando como /remmulta para remover a multa ou simplesmente zerar a variavel booleana, caso contrбrio a pessoa nгo poderб tomar mais que 1 multa!


Re: Usar esse comando 1x no mesmo id - RianRBS - 03.05.2016

Valeu cara funcionou ^^


Re: Usar esse comando 1x no mesmo id - BrianD - 03.05.2016

lembre-se de criar um timer para dar um reset na UsouID[plid] caso contrario nunca mais poderб multar aquele id em quanto nгo der gmx


Re: Usar esse comando 1x no mesmo id - RianRBS - 03.05.2016

Pow tu pode fazer isso pra mim eu nгo sei, eu nгo manjo muito eu sу sei editar comando pбh editar a gm e criar poucas coisas


Re: Usar esse comando 1x no mesmo id - RianRBS - 03.05.2016

Quote:
Originally Posted by BrianD
Посмотреть сообщение
lembre-se de criar um timer para dar um reset na UsouID[plid] caso contrario nunca mais poderб multar aquele id em quanto nгo der gmx
Pow tu pode fazer isso pra mim eu nгo sei, eu nгo manjo muito eu sу sei editar comando pбh editar a gm e criar poucas coisas


Re: Usar esse comando 1x no mesmo id - F1N4L - 03.05.2016

Vai zerar de 5 em 5 minutos
Код:
public OnGameModeInit()
{
	SetTimer("ResetarMultados", 300000, true);
	return 1;
}

forward ResetarMultados();
public ResetarMultados()
{
	for(new i = 0; i < MAX_PLAYERS; i ++) UsouID[i] = false;
	
	return 1;
}



Re: Usar esse comando 1x no mesmo id - Whoo - 03.05.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Vai zerar de 5 em 5 minutos
Код:
public OnGameModeInit()
{
	SetTimer("ResetarMultados", 300000, true);
	return 1;
}

forward ResetarMultados();
public ResetarMultados()
{
	for(new i = 0; i < MAX_PLAYERS; i ++) UsouID[i] = false;
	
	return 1;
}
F1N4L, recomendo que dispare o timer quando ele for multado pra evitar bug de acabar de multar e na sorte for no mesmo momento do timer zerar.


Re: Usar esse comando 1x no mesmo id - RianRBS - 03.05.2016

Quote:
Originally Posted by Whoo
Посмотреть сообщение
F1N4L, recomendo que dispare o timer quando ele for multado pra evitar bug de acabar de multar e na sorte for no mesmo momento do timer zerar.
Vocк pode colocar os codigos no comando do F1N4L e me mandar denovo? Porque aqui estб dando erros provavelmente estуu colocando errado '


Re: Usar esse comando 1x no mesmo id - F1N4L - 03.05.2016

Quote:
Originally Posted by Whoo
Посмотреть сообщение
F1N4L, recomendo que dispare o timer quando ele for multado pra evitar bug de acabar de multar e na sorte for no mesmo momento do timer zerar.
Vocк tem toda a razгo.

Recomendo desta forma:
Код:
new bool:UsouID[MAX_PLAYERS];

if(strcmp(cmd, "/multar", true) == 0) 
{
	new aname[MAX_PLAYER_NAME];
	
	GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
	
	format(file, sizeof(file), PASTA_CONTAS, aname);
	
	if(dini_Int(file, "Profissao") == Policial_C || dini_Int(file, "Profissao") == Policial_F || dini_Int(file, "Profissao") == Delegado || dini_Int(file, "Profissao") == Bope || dini_Int(file, "Profissao") == Swat || dini_Int(file, "Profissao") == Narcoticos || dini_Int(file, "Profissao") == Policial_M || dini_Int(file, "Profissao") == FBI || dini_Int(file, "Profissao") == Interpol || dini_Int(file, "Profissao") == LSPD || dini_Int(file, "aAdmin") == 1 || IsPlayerAdmin(playerid))
	{
		new tmp[256];
		new plid;
		
		new quant;
		
		tmp = strtok(cmdtext, idx);
		
		if(!strlen(tmp)) 
		{
			SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
			return 1;
		}
		
		plid = strval(tmp);
		
		tmp = strtok(cmdtext, idx);
		
		if(!strlen(tmp)) 
		{
			SendClientMessage(playerid, Vermelho, "/multar [id] [quantidade]");
			return 1;
		}
		
		if(UsouID[plid] == true) return SendClientMessage(playerid, Vermelho, "Esse ID jб foi utilizado!");
		
		quant = strval(tmp);
		
		if(quant > 1000 || quant <= 0)
		{
			SendClientMessage(playerid, Vermelho, "(INFO) Vocк nгo estб multando de forma justa.");
			return 1;
		}
		
		if(IsPlayerConnected(plid))
		{
			new pname[MAX_PLAYER_NAME];
			
			GetPlayerName(plid, pname, MAX_PLAYER_NAME);
			
			format(file2, sizeof(file2), PASTA_CONTAS, pname);
			
			format(string, sizeof(string), "(INFO) Vocк recebeu uma multa de R$%d Pelo policial %s . O dinheiro foi retirado do banco.", quant, aname);
			SendClientMessage(plid, COLOR_GREEN, string);
			
			SendClientMessage(playerid, COLOR_GREEN, "(INFO) Multa dada.");
			
			UsouID[plid] = true;
			
			SetTimerEx("ResetarMultados", 300000, true, "i", plid);
			
			dini_IntSet(file2, "SaldoBancario", dini_Int(file2, "SaldoBancario")- quant);
			return 1;
		}
		else
		{
			SendClientMessage(playerid, Vermelho, "(INFO) O jogador nгo estб conectado!");
			return 1;
		}
	}
}

forward ResetarMultados(playerid);
public ResetarMultados(playerid) return UsouID[playerid] = false;