SA-MP Forums Archive
Please help make - 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: Please help make (/showthread.php?tid=382002)



Please help make - Andrew163 - 01.10.2012

Hello, how to make that only administrators wrote in a chat when players use the command. For example: a player "Nickname" uses the command "/car"?



Код:
COMMAND:car(playerid, params[])
{
	if(Player[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_RED, "Вы не администратор.");
	{
	new string[128], carid, carcolor1, carcolor2;
	if(!sscanf(params, "iii", carid, carcolor1, carcolor2)){
	if(carid >= 400 && carid <= 611){
	if(carcolor1 >= 0 && carcolor1 <= 252){
	if(carcolor2 >= 0 && carcolor2 <= 252){
	new Float:X, Float:Y, Float:Z;
	GetPlayerName(playerid, sendername, sizeof(sendername));
	GetPlayerPos(playerid, X, Y, Z);
	CreateVehicle(carid, X+4, Y, Z, 10, carcolor1, carcolor2, 100);
	format(string, sizeof(string), "Вы заспавнили автомобиль %s [ID: %d] с цветами [%d, %d]",VehicleNames[carid-400], carid, carcolor1, carcolor2);
	return SendClientMessage(playerid,COLOR_GREEN, string);}
	else return SendClientMessage(playerid, COLOR_RED, "Неверный ID цвета!Используйте числа от 0 до 252.");}
	else return SendClientMessage(playerid, COLOR_RED, "Неверный ID цвета!Используйте числа от 0 до 252.");}
	else return SendClientMessage(playerid, COLOR_RED, "Неверный ID транспорта!Используйте от 400 до 611.");}
	else return SendClientMessage(playerid, COLOR_GREEN, "Используйте: /car [ID] [цвет 1][цвет 2].");
}
}



Re: Please help make - gtakillerIV - 01.10.2012

Use OnPlayerCommandPerformed:-

Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	new str[128],name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	if(success)
	{
		format(str, sizeof(str), "Cmd: %s(id:%d) has used the command '%s'", name, playerid, cmdtext);
		SendMessageToAdmins(Grey, str);
	}
	if(!success)
	{
	    if(ServerInfo[ShowTypedCommands] ==0) return 0;
		SendClientMessage(playerid, Yellow, "Unkown Command. Use /cmds  to see the list of available "green"commands");
		format(str, sizeof(str), "Cmd: %s(id:%d) has used the command '%s'", name, playerid, cmdtext);
		SendMessageToAdmins(Grey, str);
	}
	return 1;
}
Код:
stock SendMessageToAdmins(color,const msg[])
{
	for (new i=0; i<MAX_PLAYERS; i++)
	{
		if (IsPlayerConnected(i))
		{
			switch(PlayerInfo[i][pAdminLevel])
			{
				case 2:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 3:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 4:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 5:
				{
			    	SendClientMessage(i,color,msg);
				}
				case 6:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 7:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 8:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 9:
				{
			    	SendClientMessage(i,color,msg);
				}

				case 10:
				{
			    	SendClientMessage(i,color,msg);
				}

				default:
				{
			    	return 0;
				}
			}
		}
	}
	return 1;
}



Re: Please help make - Andrew163 - 02.10.2012

Код:
D:\Games\SAMP сервер\SampDM\gamemodes\SampDMv.1.3.pwn(3771) : error 017: undefined symbol "ServerInfo"
D:\Games\SAMP сервер\SampDM\gamemodes\SampDMv.1.3.pwn(3771) : error 017: undefined symbol "ShowTypedCommands"
D:\Games\SAMP сервер\SampDM\gamemodes\SampDMv.1.3.pwn(3771) : error 029: invalid expression, assumed zero
D:\Games\SAMP сервер\SampDM\gamemodes\SampDMv.1.3.pwn(3771) : fatal error 107: too many error messages on one line
Код:
if(ServerInfo[ShowTypedCommands] == 0) return 0;
//line 3771


Re: Please help make - gtakillerIV - 02.10.2012

My BIG mistake remove that line please
Код:
if(ServerInfo[ShowTypedCommands] == 0) return 0;



Re: Please help make - CmZxC - 02.10.2012

i bet 5 bucks on fact that he will get another error about admin levels.


Re: Please help make - Andrew163 - 02.10.2012

I am, deletes a row and there are other errors ... How to fix?


Re: Please help make - Danyal - 02.10.2012

how do we know if you wont post errors with the line containing error??


Re: Please help make - Andrew163 - 02.10.2012

In this line error
Код:
if(ServerInfo[ShowTypedCommands] == 0) return 0;
Not enough "enum ServerInfo"?


Re: Please help make - Danyal - 02.10.2012

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    new str[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(success)
    {
        format(str, sizeof(str), "Cmd: %s(id:%d) has used the command '%s'", name, playerid, cmdtext);
        SendMessageToAdmins(Grey, str);
    }
    if(!success)
    {
        SendClientMessage(playerid, Yellow, "Unkown Command. Use /cmds  to see the list of available "green"commands");
        format(str, sizeof(str), "Cmd: %s(id:%d) has used the command '%s'", name, playerid, cmdtext);
        SendMessageToAdmins(Grey, str);
    }
    return 1;
}



Re: Please help make - CmZxC - 02.10.2012

I am still not understanding what the hell does this line have to do anything to this topic
pawn Код:
SendClientMessage(playerid, Yellow, "Unkown Command. Use /cmds  to see the list of available "green"commands");