| kaicer666   Gremlin
 
  
   Posts: 5
 Joined: Jul 2013
 Reputation: 0
 Version: 
1.4.3.143
 
 | 
			| Help with a script 
 
				some knows what is wrong?????(im new on this)
 function Chat(chatType, nick, msg)
 if ((chatType == 1) or (chatType == 2) or (chatType == 6) or (chatType == 7)) then
 ShowToClient("Alarm","Someone may just petitioned you.");
 PlaySound(GetDir() .. "alarm.wav");
 Command("/useshortcut 10 1"); --> this is a macro
 end;
 end;
 |  | 
	| 01-31-2015 13:21 PM |  | 
	
		| Pelukis   MaboX
 
   
 Posts: 50
 Joined: Oct 2014
 Reputation: 21
 Version: 
1.4.2.138
 
 | 
			| RE: Help with a script 
 
				no need VIP..     LUA Programming
	AlarmStatus = false;
 
function OnCreate()
	this:RegisterCommand("alarm", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME );
end;
 
function OnCommand_alarm(vCommandChatType, vNick, vCommandParam)
	AlarmStatus = not AlarmStatus;
 	local state = AlarmStatus and "Activated" or "Deactivated";
 	ShowToClient( "Alarm Status", "Is " .. state );
end;
 
function OnChatUserMessage(chatType, nick, msg)
	if ((chatType == 1) or (chatType == 2) or (chatType == 6) or (chatType == 7)) and AlarmStatus then 
		PlaySound(GetDir() .. "alarm.wav");
		ShowToClient("Alarm","Someone may just petitioned you.");
		Command("/useshortcut 10 1"); --> this is a macro
	end;
end; 
this is plugin save as filename.lua and save to l2tower "plugin" folder 
copy file "alarm.wav" on root folder of L2tower
			 |  | 
	| 02-01-2015 11:05 AM |  | 
|  Reputed by : | kaicer666(+1) | 
	
		| kaicer666   Gremlin
 
  
   Posts: 5
 Joined: Jul 2013
 Reputation: 0
 Version: 
1.4.3.143
 
 | 
			| RE: Help with a script 
 
				thx a lot, i fixed yesterday xD and its pretty the same code.. this is 
Code:
 alarm = false;
 function OnCreate()
 this:RegisterCommand("alarm", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
 end;
 
 function OnCommand_alarm(vCommandChatType, vNick, vCommandParam)
 
 if (alarm == false) then
 alarm = true;
 ShowToClient("Alarm","Alarma Activada");
 else
 alarm = false;
 ShowToClient("Alarm","Alarma Desactivada");
 end;
 
 end;
 
 
 function OnChatUserMessage(chatType, nick, msg)
 if (((chatType == 2) or (chatType == 6) or (chatType == 7))) then
 ShowToClient("Alarm","Someone may just petitioned you.");
 PlaySound(GetDir() .. "alarm.wav");
 Command("#Urrakataca!");
 end;
 end;
 
 function OnLTick1s()
 if (GetMe():IsAlikeDeath() == false ) then
 
 playerlist = GetPlayerList();
 playerid = nil;
 
 for player in playerlist.list do
 
 if (player:IsMyPartyMember() == false) and (player:IsEnemy()) and (player:GetReputation() < 0) and (player:GetDistance() < 1600) and (player:IsFriend() == false) and (player:IsAlikeDeath() == false) then
 playertarget = GetUserById(player:GetTarget());
 if (playertarget ~= nil) then
 if (playertarget:IsMyPartyMember()) or (playertarget:IsMe()) then
 playerid = player:GetId();
 name=player:GetName();
 end;
 end;
 end;
 
 if (player:IsMyPartyMember() == false) and (player:IsPvPFlag()) and not (player:IsPvPFlagBlink()) and (player:GetDistance() < 1600) and (player:IsAlikeDeath() == false) then --and (player:IsFriend() == false) and (player:IsEnemy())
 playertarget = GetUserById(player:GetTarget());
 if (playertarget ~= nil) then
 if (playertarget:IsMyPartyMember()) or (playertarget:IsMe()) then
 playerid = player:GetId();
 name=player:GetName();
 end;
 end;
 end;
 
 end;
 
 end;
 
 if ( playerid ~= nil and GetMe():IsAlikeDeath() == false ) then
 
 PlaySound(GetDir() .. "alarm.wav");
 
 ShowToClient("Alarm"," - " .. tostring(name) .. " attacked you!!");
 
 
 end;
 
 end;
 
and the last question: what is ChatType for general chat i mean white chat?
			
				
(This post was last modified: 02-02-2015 09:28 AM by kaicer666.)
 |  | 
	| 02-02-2015 08:57 AM |  |