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

Giving people points once


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-12-2016 , 22:24   Giving people points once
Reply With Quote #1

Hello Alliedmodders,

I want to make a plugin that gives people a "sack" of points when they say /freepoints . But how would I be able to only to let them have it once and if they already said /freepoints and got the points and they tried to say /freepoints again then they will get a message saying "You can't get anymore free points"
Copper is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 07-12-2016 , 22:54   Re: Giving people points once
Reply With Quote #2

You can use a bool.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
Copper
Senior Member
Join Date: Feb 2012
Location: California
Old 07-12-2016 , 23:38   Re: Giving people points once
Reply With Quote #3

thanks i got it.
Copper is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 07-16-2016 , 13:36   Re: Giving people points once
Reply With Quote #4

Quote:
Originally Posted by wickedd View Post
You can use a bool.
using this way they can reconnect and get points again.
__________________
JusTGo is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-16-2016 , 15:13   Re: Giving people points once
Reply With Quote #5

i prefer using bitsum

PHP Code:
#define give_freepoints(%1)       user_got_freepoints |= (1<<%1)
#define remove_freepoints(%1)  user_got_freepoints &= ~(1<<%1)
#define has_freepoints(%1)        user_got_freepoints & (1<<%1)

new user_got_freepoints

public plugin_init()
{
   
register_clcmd("say /freepoints""clcmd_freepoints")
}

public 
clcmd_freepoints(id)
{
        if(!
g_has_freepoints(id))
        {
                  
give_freepoints(id)
                  
// user give free points
        
}

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-16-2016 , 15:21   Re: Giving people points once
Reply With Quote #6

Quote:
Originally Posted by Natsheh View Post
i prefer using bitsum

PHP Code:
#define give_freepoints(%1)       user_got_freepoints |= (1<<%1)
#define remove_freepoints(%1)  user_got_freepoints &= ~(1<<%1)
#define has_freepoints(%1)        user_got_freepoints & (1<<%1)

new user_got_freepoints

public plugin_init()
{
   
register_clcmd("say /freepoints""clcmd_freepoints")
}

public 
clcmd_freepoints(id)
{
        if(!
g_has_freepoints(id))
        {
                  
give_freepoints(id)
                  
// user give free points
        
}

You will lose data if you left shift 32 bits. To handle this, use 1 << ( id & 31 )
__________________

Last edited by Bugsy; 07-16-2016 at 15:22.
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-16-2016 , 15:48   Re: Giving people points once
Reply With Quote #7

0000 1000 = 8
0001 1111 = 31
------------ &
0000 1000 = 8
------------

Yh Its a better way cause max players is 31 slot.

apologize on my fault
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-16-2016 , 15:50   Re: Giving people points once
Reply With Quote #8

Max player id is 32 which is where you would have an issue. Using id & 31 fixes this.
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 11:23.


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