AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   in the first 3 minutes of the map (https://forums.alliedmods.net/showthread.php?t=46638)

ch3cker 10-30-2006 09:45

in the first 3 minutes of the map
 
hi

i want to use only knife in the first 3 minutes of the map.

How can I make this. With set_task or with register_event

I only need to know the thing with the first 3 minutes.

Rolnaaba 10-30-2006 09:55

Re: in the first 3 minutes of the map
 
this may work, but it uses set_task which I dont like :( :
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
public plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_event("HLTV""event_new_round""a""1=0""2=0")
}
public 
logevent_round_start() {
 for(new 
i=0;i<=get_maxplayers();i++) {
  new 
ammoclip
  
  
if(get_user_weapon(iammoclip) != CSW_KNIFE) {
   
strip_user_weapons(i)
   
give_item(iCSW_KNIFE)
   
set_task(180.0"END")
  }
 }
}
public 
END() {
 return 
PLUGIN_HANDLED



teame06 10-30-2006 13:01

Re: in the first 3 minutes of the map
 
Here is a better script. The code Rolnaaba gave you will not work at all.

Code:
#include <amxmodx> #include <amxmisc> new bool:KnifeOnly; public plugin_init() {     register_plugin("", "", "");     register_event("HLTV", "event_new_round", "a", "1=0", "2=0");     register_event("CurWeapon", "hook_CurWeapon", "be", "1=1"); } public hook_CurWeapon(player) {     if(KnifeOnly && read_data(2) != CSW_KNIFE)     {         engclient_cmd(player, "weapon_knife");     } } // Also the HLTV event won't fire off until there are actually players on each team if IIRC correctly. // So if someone join your server like like 5 minute after the map started. // This won't turn off till 8 minutes in. public event_new_round() {     KnifeOnly = true;     set_task(180.0, "NoMoreKnife");     client_print(0, print_chat, "[KNIFE] 3 minutes of knife only."); } public NoMoreKnife() {     client_print(0, print_chat, "[KNIFE] No more knife only.");     KnifeOnly = false; }

Nostrodamous 10-30-2006 16:53

Re: in the first 3 minutes of the map
 
Quote:

Originally Posted by Rolnaaba (Post 397164)
this may work, but it uses set_task which I dont like :( :

[/php]

Thank god someone fianlly feels teh same way as i do . you could also use a get_time and a reapeting while loop that breaks if(get_time)== map_start + 3min ) more complicated but possable :)

teame06 10-30-2006 18:06

Re: in the first 3 minutes of the map
 
Quote:

Originally Posted by Nostrodamous (Post 397279)
Thank god someone fianlly feels teh same way as i do . you could also use a get_time and a reapeting while loop that breaks if(get_time)== map_start + 3min ) more complicated but possable :)

@ Nostrodamous

Let me get this straight... You wanted him to do this something like this. The problem with this is that when you do a that while loop. If I'm understand what you are saying. Is that this will lock up the server for about 3 minutes in a infinite loop till it reaches it time to break out of the loop.

Code:
#include <amxmodx> new TimeToStop; public plugin_init() {     TimeToStop = get_systime() + (3 * 60);     while(TimeToStop)     {         if(get_systime() >= TimeToStop)         {             break;         }     } }

Nostrodamous 10-30-2006 18:37

Re: in the first 3 minutes of the map
 
no , no no , notice i was speaking to rolnaaba. i was not suggesting that he used that method , i simply stated that that was an "option". but in this sitaution it would be better to use a set task function , set_task function are best for sitautions like this when you need to set an actaul time to do a function .

MaximusBrood 10-31-2006 03:48

Re: in the first 3 minutes of the map
 
set_task() is just a legimate function that you need sometimes.
There is nothing bad about it other then being quite CPU intensive.
You can't just take a while loop and loop until the time reaches "map_start + 3min", it will lockup the server.

[ --<-@ ] Black Rose 11-04-2006 19:42

Re: in the first 3 minutes of the map
 
Code:
#include <amxmodx> new bool:KnifeOnly; new bool:first = true; public plugin_init() {     register_plugin("", "", "");         register_event("HLTV", "event_new_round", "a", "1=0", "2=0");     register_event("CurWeapon", "hook_CurWeapon", "be", "1=1"); } public hook_CurWeapon(player) {     if ( KnifeOnly && read_data(2) != CSW_KNIFE )         engclient_cmd(player, "weapon_knife"); } public event_new_round() {     if ( ! first )         return;         KnifeOnly = true;     set_task(180.0, "NoMoreKnife");     client_print(0, print_chat, "[KNIFE] 3 minutes of knife only.");     first = false; } public NoMoreKnife() {     client_print(0, print_chat, "[KNIFE] No more knife only.");     KnifeOnly = false; }

VEN 11-05-2006 02:42

Re: in the first 3 minutes of the map
 
Quote:

the HLTV event won't fire off until there are actually players on each team if IIRC correctly
No, HLTV is a global event and given params (0, 0) have nothing to do with a player so it will fire on every new round, not taking players in account.

teame06 11-05-2006 05:11

Re: in the first 3 minutes of the map
 
Quote:

Originally Posted by VEN (Post 399844)
No, HLTV is a global event and given params (0, 0) have nothing to do with a player so it will fire on every new round, not taking players in account.

Yes it does. HLTV event will not fire off with the condition 1=0 and 2=0 when the server starts up with no players in the server. I have tested it just right now. The only time I see that event fire off is when the each team has a player or a single person on join a team and then kill himself or force a round restart.


All times are GMT -4. The time now is 04:53.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.