AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Several Easy Hl Coding Questions (https://forums.alliedmods.net/showthread.php?t=24691)

SickMothaF 03-01-2006 03:11

Several Easy Hl Coding Questions
 
Hello everyone. I am new to the HL1 coding and I just want to ask you guys some easy (for you I guess) stuff that I want to achieve.

1. How to create a timer that is visible on screen that counts from 00:00:00 till the end of the level, and how to write that time out in log000001.txt for example. The next player that plays the level will have log000002.txt and so long.

2. How to disable mouse from the game, I just want the arrow keys and space key.

3. Before every level I want to have a black screen that tells you to press space to begin level 1, and a black screen after you finished the level that tells you to press space to go to level 2.

4. I want to have a time stamp when a weapon is picked up in the log000001.txt.

Thank you all that can help me in advance. I will really appreciate the help!

broertje 03-01-2006 03:24

i'm new to,but i think for (1) you need a get_timeleft and create a place with hudgenerator i think???

broertje 03-01-2006 03:40

I tried something,got 6 warnings,so if anyone could help me a little bit.
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_cvar("amx_counter", "1") }     public mess(id)     {         new timel         get_timeleft(timel,32)     if ( !get_cvar_num("amx_counter") )     {           set_hudmessage(255, 255, 255, 0.00, 0.00, 0, 6.0, 12.0)              show_hudmessage(id, "%s Remaining",timel)         return PLUGIN_HANDLED     } }

SickMothaF 03-01-2006 05:15

Hello, thank you verry much. But I think that u've missunderstood me. I want to create not a time left, but a simple timer display starting from 00:00:00 and when you finish one level at the end of the level you will get on a black screen for example or in a logfile (the better) like Map1 finished in 00:02:34
Map2 finished in 00:14:22 total time 16 min and 56 sec.

MaximusBrood 03-01-2006 11:51

Quote:

Originally Posted by SickMothaF
Hello, thank you verry much. But I think that u've missunderstood me. I want to create not a time left, but a simple timer display starting from 00:00:00 and when you finish one level at the end of the level you will get on a black screen for example or in a logfile (the better) like Map1 finished in 00:02:34
Map2 finished in 00:14:22 total time 16 min and 56 sec.

A logfile is a lot simpler :D

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> new PLUGIN[] = "Maptime log" new VERSION[] = "0.1" new AUTHOR[] = "MaximusBrood" new beginTime public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         //Record the starting time     LogStartTime() } public LogStartTime() {     beginTime = get_systime()         return PLUGIN_HANDLED } public plugin_end() {     new endTime = get_systime()     new iseconds = beginTime - endTime     new iminutes = 0, ihours = 0             //Minutes     if(iseconds > 59)     {         iminutes = iseconds / 60         iseconds -= iminutes * 60     }         //Hours     if(iminutes > 59)     {         ihours = iminutes / 60         iminutes -= ihours * 60     }         new len = 0, result[128]     //Collect output     if(ihours != 0)     {         len += format(result[len], 127, "%d hours, ", ihours)     }     if(iminutes != 0)     {         len += format(result[len], 127, "%d minutes and", iminutes)     }         len += format(result[len], 127, "%d seconds", iseconds)         new mapname[64]     get_mapname(mapname, 63)         //Log output     log_amx("The map %s took %s", mapname, result)         return PLUGIN_HANDLED }

Compiles ok, but not tested

:wink:

[ --<-@ ] Black Rose 03-01-2006 12:01

Code:
if(ihours != 0)         {         len += format(result[len], 127, "%d %s, ", ihours, ihours == 1 ? "hour" : "hours")     }     if(iminutes != 0)         {         len += format(result[len], 127, "%d %s and", iminutes, iminutes == 1 ? "minute" : "minutes")     }         len += format(result[len], 127, "%d %s", iseconds, iseconds == 1 ? "second" : "seconds")
would just look btr

MaximusBrood 03-01-2006 13:04

No... it won't...

Thats a really 'hard to see' identing style :?

I think my style is much better :)

---

Look at these two examples

Code:
if(bla == blah) {     for(int a = 0; a < max; a++)     {         for(int b = 0; a < max2; b++)         {             if(something == something)             {                 DoThis();             } else             {                 if(anotherthing == something)                 {                     DoThat();                 } else                 {                     DoTheOtherThing();                 }             }                 //Add a thing             AddThing(thing);         }             ResetThis(value)     } } else {     EscapeSomeData('@', 127); }

Code:
if(bla == blah)     {     for(int a = 0; a < max; a++)         {         for(int b = 0; a < max2; b++)             {             if(something == something)                 {                 DoThis();             } else                 {                 if(anotherthing == something)                     {                     DoThat();                 } else                     {                     DoTheOtherThing();                 }             }                 //Add a thing             AddThing(thing);         }             ResetThis(value)     } } else     {     EscapeSomeData('@', 127); }

You can immidiatly see what piece of code is in what loop with the first style.
You can't really see with the seconds style :D

SickMothaF 03-01-2006 14:16

Hi, thanks! But I have some problems with the mod. I compiled MaximusBrood's code and put it in to the plugins.ini . My liblist gam is

game "Maze rat"
startmap "maze1"
trainmap "t0a0"
mpentity "info_player_deathmatch"

cldll "cl_dlls\client.dll"
gamedll "addons\metamod\dlls\metamod.dll"
gamedll_linux "addons/metamod/dlls/metamod_i386.so"

The game crashesh every time I start new game (or load a map.) I thought that it was from the compiled plugin but when i removed it , it is the same - crash. May be something is wrong with amx ?

MaximusBrood 03-01-2006 14:59

Look here, its perfectly explained :D

http://wiki.amxmodx.org/index.php/In...ally#Configure

[ --<-@ ] Black Rose 03-01-2006 15:13

lol i meant the
Code:
iseconds == 1 ? "second" : "seconds"
not the identing
i would have done it like so:
Code:
// if(ihours != 0) {     len += format(result[len], 127, "%d %s, ", ihours, ihours == 1 ? "hour" : "hours") } if(iminutes != 0) {     len += format(result[len], 127, "%d %s and", iminutes, iminutes == 1 ? "minute" : "minutes") } len += format(result[len], 127, "%d %s", iseconds, iseconds == 1 ? "second" : "seconds") //


All times are GMT -4. The time now is 20:19.

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