Raised This Month: $51 Target: $400
 12% 

Action Progress like when planting/defusing bomb


Post New Thread Reply   
 
Thread Tools Display Modes
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-30-2005 , 20:43  
Reply With Quote #11

Thanks xero!

So you're saying something like this?

Code:
// ..     register_clcmd("+plant","doPlant")     register_clcmd("-plant","unPlant")     // .. public doPlant(id) {     if(!task_exists(id)) {         set_task(3.0,"doPlant",id, ... ) // Hmm     }     message_begin( MSG_ONE_UNRELIABLE, 108, {0,0,0}, id )     write_byte( 3 )     write_byte( 0 )     message_end()     return PLUGIN_HANDLED } public unPlant(id) {     if(task_exists(id)) {         message_begin( MSG_ONE_UNRELIABLE, 108, {0,0,0}, id )         write_byte( 0 )         write_byte( 0 )         message_end()     }     return PLUGIN_HANDLED }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-01-2005 , 01:15  
Reply With Quote #12

Ya, but more like:


Code:
#define PLANT_TASK 5567     // ..     register_clcmd("+plant","doPlant")     register_clcmd("-plant","unPlant")     // .. public doPlant(id) {     if(!task_exists(PLANT_TASK + id)) {         new szCmdArgs[2]         szCmdArgs[0] = id         set_task(3.0,"PlantMine", PLANT_TASK+id, szCmdArgs, 1 )         message_begin( MSG_ONE_UNRELIABLE, 108, {0,0,0}, id )         write_byte( 3 )         write_byte( 0 )         message_end()     }     return PLUGIN_HANDLED } public unPlant(id) {     if(task_exists(id)) {         message_begin( MSG_ONE_UNRELIABLE, 108, {0,0,0}, id )         write_byte( 0 )         write_byte( 0 )         message_end()         // Remove the task, since progress bar was incomplete...         remove_task( PLANT_TASK + id )     }     return PLUGIN_HANDLED } public PlantMine( szCmdArgs[] ) {     new id = szCmdArgs[0]     client_print( id, print_chat, "You planted a mine!" )     // Put your actual Mine Entity create code here...     return PLUGIN_HANDLED }


I used a constant Task ID as a base, so that other plugin tasks dont collide, like if 2 plugins have task IDs that are player IDs.. this way it is a player ID + a constant, making it more unique for a task ID..
xeroblood is offline
Send a message via MSN to xeroblood
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-01-2005 , 01:29  
Reply With Quote #13

Oh, hmmm..

Why do you always use sz in front of your vars?
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-01-2005 , 11:41  
Reply With Quote #14

Well, in University I learned Hungarian Notation, which is just a naming convention...
All integers start with a small i, all floats start with a small f, all strings start with an s, and null-terminated strings (like in Small C) start with an sz..
Also, all of my globals would start with g_

So, if I had a global string to hold a name for example, I would use:

g_szName

That way later in my code, I would automatically know that this variable is global, and it is a null-terminated string. And I wouldn't have to go and look up the declaration to know that..

It isn't neccessary, just a habit I got into...
xeroblood is offline
Send a message via MSN to xeroblood
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 05-01-2005 , 12:15  
Reply With Quote #15

The age old advice: don't invent new cmds to bind buttons to. People are stupid and don't know how to bind their shoelaces. ;-)

You can look at a plugin I made awhile back: The Stealth Bag: http://forums.alliedmods.net/showthread.php?p=85752
It has progress bars, and uses the normal USE button for everything. No new cmds to bind buttons to needed at all.
Johnny got his gun is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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