SA-MP Forums Archive
Check my codes. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Check my codes. (/showthread.php?tid=571894)



Check my codes. - ChuckyBabe - 23.04.2015

Is my code correct ? I want to start the timer for the player not the admin who is using it check it here

Код:
CMD:ban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/partofname] [reason]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
			{
				if(AdminDuty[playerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(playerid, "TempNameName", username, sizeof(username));
					SetPVarInt(playerid, "TempName", 0);
					SetPlayerName(playerid, username);
				}
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", PlayerInfo[playerid][pAdminName]);
				ABroadCast(COLOR_YELLOW,string,1);
				PlayerInfo[playerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(playerid,ip,sizeof(ip));
				AddBan(ip);
				SetTimerEx("DelayedKick", 1000, false, "i", playerid);
				return 1;
			}
			else
			{
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));

				if(AdminDuty[giveplayerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(giveplayerid, "TempNameName", username, sizeof(username));
					SetPVarInt(giveplayerid, "TempName", 0);
					SetPlayerName(giveplayerid, username);

					format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], GetPlayerNameEx(playerid), reason);
					SetTimerEx("DelayedKick", 1000, false, "i", playerid);
				}
				else
				{
					format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
					SetTimerEx("DelayedKick", 1000, false, "i", playerid);
				}


				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				PlayerInfo[giveplayerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
				AddBan(ip);
				SetTimerEx("DelayedKick", 1000, false, "i", playerid);
				return 1;
			}

		} else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	return 1;
}
I'am confused where i will use the 'playerid' and 'giveplayerid' +1 rep!


Re: Check my codes. - BleverCastard - 23.04.2015

SetTimerEx("DelayedKick", 1000, false, "i", playerid); it should be giveplayerid. Change it where it's needed.


Re: Check my codes. - ChuckyBabe - 23.04.2015

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
SetTimerEx("DelayedKick", 1000, false, "i", playerid); it should be giveplayerid. Change it where it's needed.
I'am asking where in the code that I will change it.


Re: Check my codes. - BleverCastard - 23.04.2015

Dude. I could not be any more simpler to you. I even extracted the code from your code and told you WHAT TO DO. Please for the love of god, learn. CHANGE PLAYERID TO GIVEPLAYERID


Re: Check my codes. - ChuckyBabe - 23.04.2015

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
Dude. I could not be any more simpler to you. I even extracted the code from your code and told you WHAT TO DO. Please for the love of god, learn. CHANGE PLAYERID TO GIVEPLAYERID
You mean all

Код:
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
that i have on my code will be this.

Код:
SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);



Re : Check my codes. - Golimad - 23.04.2015

Код:
CMD:ban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/partofname] [reason]");

		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
			{
				if(AdminDuty[playerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(playerid, "TempNameName", username, sizeof(username));
					SetPVarInt(playerid, "TempName", 0);
					SetPlayerName(playerid, username);
				}
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", PlayerInfo[playerid][pAdminName]);
				ABroadCast(COLOR_YELLOW,string,1);
				PlayerInfo[playerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(playerid,ip,sizeof(ip));
				AddBan(ip);
				SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);
				return 1;
			}
			else
			{
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));

				if(AdminDuty[giveplayerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(giveplayerid, "TempNameName", username, sizeof(username));
					SetPVarInt(giveplayerid, "TempName", 0);
					SetPlayerName(giveplayerid, username);

					format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], GetPlayerNameEx(playerid), reason);
					SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);
				}
				else
				{
					format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
					SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);
				}


				SendClientMessageToAllEx(COLOR_LIGHTRED, string);
				PlayerInfo[giveplayerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
				AddBan(ip);
				SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);
				return 1;
			}

		} else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	return 1;
}



Re: Check my codes. - BleverCastard - 23.04.2015

Quote:
Originally Posted by ChuckyBabe
Посмотреть сообщение
You mean all

Код:
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
that i have on my code will be this.

Код:
SetTimerEx("DelayedKick", 1000, false, "i", giveplayerid);
Yes, exactly like that.


Re: Check my codes. - Konstantinos - 23.04.2015

Quote:
Originally Posted by BleverCastard
Посмотреть сообщение
Dude. I could not be any more simpler to you. I even extracted the code from your code and told you WHAT TO DO. Please for the love of god, learn. CHANGE PLAYERID TO GIVEPLAYERID
He has that line 4 times so it's not that "simple" as the player's ID must differ.

@ChuckyBabe: use "playerid" to the line used inside:
pawn Код:
if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
and all the rest should use "giveplayerid".


Re: Check my codes. - ChuckyBabe - 23.04.2015

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
He has that line 4 times so it's not that "simple" as the player's ID must differ.

@ChuckyBabe: use "playerid" to the line used inside:
pawn Код:
if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
and all the rest should use "giveplayerid".
I already noticed that, btw thanks for replying legend.