Raised This Month: $ Target: $400
 0% 

Limit uses


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-11-2005 , 20:03   Limit uses
Reply With Quote #1

Alright, I know this is simple but I'm not sure how to do it. Say I'd want to limit the use of a certain command to 3 times per round, how would I do this?
__________________
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
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-11-2005 , 20:22  
Reply With Quote #2

its quite simple actually.
1. Hook the command to a function
2. Make an array that will hold everyones 'command status' like new timesused[32]
3. When the command is ran, use an if statement to see if timesused[id] >= 3. Then return PLUGIN_HANDLED. (optional: write a client_print or do somethign more advanced)
4. then do an else statement
5. timesused[id]++
6. Do what ever the command ussually does; or return PLUGIN_CONTINUE if its a command that is built into HL.
7. You can either use logevent or just event to hook a new round or ResetHud, which will then run a function that does
Code:
for (new i = 0; i<sizeof(timesused);i++){
timesused[i] = 0
}
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-11-2005 , 20:32  
Reply With Quote #3

So.. somethin like this..
Code:
public myFunction(id) {     new timesUsed[32]     if(timesUsed == 3) {     return PLUGIN_HANDLED     }     else {     // do something..     timesUsed[id]++     } }
__________________
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
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-11-2005 , 20:38  
Reply With Quote #4

Code:
new timesUsed[32] //Forgot to mention this was a global varible. public myFunction(id) {         if(timesUsed[id] == 3) {     return PLUGIN_HANDLED     }     else {     // do something..     timesUsed[id]++     } }

also to reset the commadn count every round
Code:
register_event("ResetHUD","event_resethud","b"); // in plugin_init public event_resethud(){ for(new i=0;i<sizeof(timesUsed);i++) { timesUsed[i] = 0 } return PLUGIN_CONTINUE }

however, someoen can reset their command usage by typing fullupdate in console. you might want to block that.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-11-2005 , 20:48  
Reply With Quote #5

Alright, thanks..

Yea, I'll block that.. =]
__________________
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
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-11-2005 , 21:04  
Reply With Quote #6

Player indexes are from 1 - 32.

An array with a size of 32 has indexes from 0 - 31.

You could possibly get an out-of-bounds error.

Declare your array with a size of 33.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 03-11-2005 , 21:05  
Reply With Quote #7

Will do.
__________________
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
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-11-2005 , 21:05  
Reply With Quote #8

well typo, besides i never play with a max 32 server anyway.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-11-2005 , 21:07  
Reply With Quote #9

But that doesn't mean the people running your plugins don't. :-P
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-11-2005 , 21:08  
Reply With Quote #10

there is a rare amount of servers (well comparted to the total of all servers) that run max 32, and if someone did, whats the chance of them choosing one of my plugins?

even though i know i should use [33]..
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
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 14:06.


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