Raised This Month: $ Target: $400
 0% 

[HELP]How to make points as deathrun?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Infernuz
Member
Join Date: May 2011
Old 08-31-2012 , 21:27   Re: [HELP]How to make points as deathrun?
Reply With Quote #4

No I don't know "deathrun shops" since I haven't played on those servers. But I can help with points.

You can create a array of players for which will hold all players points like this.

We assume that this are our 32 players
PHP Code:
new deathrun_points[32] = 0
And this is our function to call when a player clicks on it.

myMenuItem(id, item) - Where id is a player identificator and item is an integer.
case 1: - Is a grenade that costs 500$.

PHP Code:
public myMenuItem(iditem) {
    new 
user_money cs_get_user_money(id);
    
    switch(
item) {
        case 
1: {
            if(
user_money >= 500) {
                
// bla bla, give player a grenade.
                
                // this removes 500 from their money.
                
cs_set_user_money(iduser_money 500); 
            }
        }
        
// more other cool items.
    
}
}


We want to perfom a check if player have any points, so now we modify this function a bit so it looks like this.

PHP Code:
public myMenuItem(iditem) {
    new 
user_money cs_get_user_money(id);
        
    switch(
item) {
        case 
1: {
            if(
user_money >= 500) {
                
// bla bla, give play grenade.
                
                // this removes 500 from their money.
                
cs_set_user_money(iduser_money 500); 
            } else if(
deathrun_points[id] >= 2) {
                
                
// this removes 2 points from player.
                
deathrun_points[id] = deathrun_points[id] - 2;
            } else {
                
client_cmd(1,print_chat,"Man, no money or points. Sorry, no grenade for you.");
            }
        }
        
// more other cool items.
    
}
}  


CODE FIX: If you look closely, I have modified the if statement and added an else check.


And our final code will be this.
PHP Code:
new deathrun_points[32] = 0;

public 
myMenuItem(iditem) {
    new 
user_money cs_get_user_money(id);
        
    switch(
item) {
        case 
1: {
            if(
user_money >= 500) {
                
// bla bla, give play grenade.
                
                // this removes 500 from their money.
                
cs_set_user_money(iduser_money 500); 
            } else if(
deathrun_points[id] >= 2) {
                
                
// this removes 2 points from player.
                
deathrun_points[id] = deathrun_points[id] - 2;
            } else {
                
client_cmd(1,print_chat,"Man, no money or points. Sorry, no grenade for you.");
            }
        }
        
// more other cool items.
    
}

Have you understood anything of this?

Last edited by Infernuz; 08-31-2012 at 22:31.
Infernuz is offline
Send a message via ICQ to Infernuz
 



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 08:22.


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