Raised This Month: $ Target: $400
 0% 

[HELP] Bool with two indexes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-10-2014 , 18:23   [HELP] Bool with two indexes
Reply With Quote #1

Hey, fellas! I want to ask you if there could be any bool with two indexes. Like the bool can be true just in some conditions, depending on the two indexes. I want to use it in a plugin, where I want to make a chat command just be possible only once forever. Like once you say (for example) /sayingsomething. And when you do it, something happens. but you can't make it twice. Got my idea? So, the point is - could there be a two indexed bool?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
wickedd
Veteran Member
Join Date: Nov 2009
Old 05-10-2014 , 18:58   Re: [HELP] Bool with two indexes
Reply With Quote #2

Quote:
Originally Posted by Flick3rR View Post
I want to use it in a plugin, where I want to make a chat command just be possible only once forever. Like once you say (for example) /sayingsomething. And when you do it, something happens. but you can't make it twice. Got my idea? So, the point is - could there be a two indexed bool?
You can do this. Just set your_bool to false when you want to use it again.

PHP Code:
#include <amxmodx>

new bool:your_bool33 ]

public 
plugin_init( )
{
    
register_clcmd"say /test","try_this")
}

public 
client_connectid )
{
    
your_boolid ] = false
}

public 
try_thisid )
{
    if( !
your_boolid ] )
    {
        
client_printidprint_chat"It works" )
        
your_boolid ] = true;
    }
    else
    {
        
client_printidprint_chat"You tried it already" )
    }

__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-11-2014 , 12:46   Re: [HELP] Bool with two indexes
Reply With Quote #3

No, you didn't understand me, and because I didn't explain exactly what needed. Look now, I need a bool, who can switch true or false just depending of two players. Maybe it will be more clear if I tell you what I want to use it for.
I am making a plugin, when a player can give his Karma (something like gratitude) to one other player. But I want him to give his carma only once, only one time forever. And for this I need a bool, which to set to true when hi gives his karma to right this player. But this bool needs to be true only for these both players, and for exact the second player, which the first player have already gave his carma. But the other player can give his karma and to someone else, again only once. And for thath I need something like a bool with two indexes. Got me?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 05-11-2014 , 13:05   Re: [HELP] Bool with two indexes
Reply With Quote #4

Then use an array
PHP Code:
new bool:already_gave_karma[33
Once the player gave karma set it to true
PHP Code:
already_gave_karma[id] = true 
Just and example
PHP Code:
public give_karma(giverreceiveramount)
{
    if(
already_gave_karma[giver])
        return 
//can't give again

    
karma[giver] -= amount
    karma
[receiver] += amount

    already_gave_karma
[giver] = true
    
return 1

NikKOo31 is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-11-2014 , 13:08   Re: [HELP] Bool with two indexes
Reply With Quote #5

Yea, that's simple. But now the giver could not give his karma to other people, but the idea is to can. Idk if someone can get my sick ideas, but I'll be glad if someone does. When you set this bool to true, the giver won't be able to give to other ppl, right?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-11-2014 , 13:08   Re: [HELP] Bool with two indexes
Reply With Quote #6

I think this would be better

PHP Code:
new bool:already_gave_karma[33][33]
public 
give_karma(giverreceiveramount)
{
    if(
already_gave_karma[giver][receiver])
        return 
//can't give again

    
karma[giver] -= amount
    karma
[receiver] += amount

    already_gave_karma
[giver][receiver] = true
    
return 1

__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 05-11-2014 at 13:09.
YamiKaitou is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-11-2014 , 13:16   Re: [HELP] Bool with two indexes
Reply With Quote #7

Yea, I've got that idea and tried this one out. Guess what, server crashes. And then I thought that's impossible, but since you suggest it, maybe I'll have to try again. Post the results.
EDIT: Awwwwww, that's nice. The sh*tty crash was caused by another junky plugin thath I forgot to disable. When disabled them all, this one worked. THANKS, and is good to know that bool may be with two indexes. Yami saves everyone again
__________________

Last edited by Flick3rR; 05-11-2014 at 13:22.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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 09:36.


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