AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Bool with two indexes (https://forums.alliedmods.net/showthread.php?t=240206)

Flick3rR 05-10-2014 18:23

[HELP] Bool with two indexes
 
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?

wickedd 05-10-2014 18:58

Re: [HELP] Bool with two indexes
 
Quote:

Originally Posted by Flick3rR (Post 2136156)
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" )
    }



Flick3rR 05-11-2014 12:46

Re: [HELP] Bool with two indexes
 
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?

NikKOo31 05-11-2014 13:05

Re: [HELP] Bool with two indexes
 
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



Flick3rR 05-11-2014 13:08

Re: [HELP] Bool with two indexes
 
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?

YamiKaitou 05-11-2014 13:08

Re: [HELP] Bool with two indexes
 
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



Flick3rR 05-11-2014 13:16

Re: [HELP] Bool with two indexes
 
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 :D


All times are GMT -4. The time now is 09:36.

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