AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Required_kills_for_next_level (https://forums.alliedmods.net/showthread.php?t=129071)

SaM.ThE.MaN 06-08-2010 14:05

Required_kills_for_next_level
 
Hi,
I am trying to get Required kills for next level :

PHP Code:

new PlayerXP[33]
new 
PlayerLevel[33]
new 
RequiredKills[id]

new const 
LEVELS[3] = 
{
    
1
    
2
    
4
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Required""Required""a")
}

public 
Required(id)
 {
    
RequiredKills PlayerXP -= PlayerLevel += 1


Can some one help me =.= , i have the idea of how to do it , but i cant use it by scripting.
Requiredkills = Player Xp - next Player level.

Owner123 06-08-2010 14:10

Re: Required_kills_for_next_level
 
PHP Code:

RequiredKills[attacker] = LEVELS[PlayerLevel[attacker]] - PlayerXP[attacker

BTW. Change
PHP Code:

new RequiredKills[id

to
PHP Code:

new RequiredKills[33

And what is that event "Required" ? 0o

reinert 06-08-2010 14:11

Re: Required_kills_for_next_level
 
Hook death event, then just add xp to killer, and check PlayerXP[id] if it's more than 2 then PlayerLevel++;

Xellath 06-08-2010 14:39

Re: Required_kills_for_next_level
 
Code:
new const g_iRequiredKillsPerLevel[ ] = {     16,     32,     64,     128,     256 }; new g_iLevel[ 33 ], g_iKills[ 33 ], g_iRequiredKills[ 33 ]; g_iKills[ id ] = 37; while( g_iKills[ id ] >= g_iRequiredKillsPerLevel[ g_iLevel[ id ] ] ) {     g_iLevel[ id ]++; } g_iRequiredKills[ id ] = g_iRequiredKillsPerLevel[ g_iLevel[ id ] + 1 ] - g_iKills[ id ]; // this would make the level increase, as 37 is higher than the first two values in the global variable g_iRequiredKillsPerLevel, and therefore making g_iLevel variable increase in the while() loop // g_iRequiredKills holds the value that needs to be exceeded to gain another level

Brreaker 06-09-2010 07:36

Re: Required_kills_for_next_level
 
PHP Code:

new PlayerXP[33]
new 
PlayerLevel[33]
new 
RequiredKills[id]

new const 
LEVELS[3] = 
{
    
1
    
2
    
4
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("Required""Required""a")
}
/*
public Required(id)
 {
    RequiredKills = PlayerXP -= PlayerLevel += 1

*/ 

What the **** is this?!

PHP Code:

register_event("Required""Required""a"

There is no such thing as a "required" event.You may read all the events HERE

also,
PHP Code:

new const LEVELS[3] = 
{
    
1
    
2
    
4//no comma for this one!


and
PHP Code:

new RequiredKills[id

Unless you #define id 33, this would not work :)

SaM.ThE.MaN 06-09-2010 09:35

Re: Required_kills_for_next_level
 
dude i just ripped the levels of my code and 4got to remove the , from the code.

It doesnt matter what i use, even if i do this
public Required(id)
{
(bla bla , my script is still gonna work)
}

new RequiredKills[33] , I made it id by mistake so stop eating my brains for that mistake lol

SaM.ThE.MaN 06-12-2010 04:13

Re: Required_kills_for_next_level
 
Xella ,
can you explain it to me 1 by 1 what each of the following lines in the script does , i dont wanna be spoon fed i wanna LEARN!!!

Bugsy 06-12-2010 09:15

Re: Required_kills_for_next_level
 
Here's another method which allows a Min\Max range for each rank. Also included is a SetRank function which will assign a rank to a player based on his XP points.

PHP Code:

//Constants for each rank, easier to use than number ranks
enum Ranks
{
    
Noob// 0
    
Rookie// 1
    
Good// 2
    
Best// 3
    
Pro // 4
}

//XP/point ranges for each rank.
new const RankXPRanks ][ ] = 
{
    {   
100 }, //Noob 0-100 pts
    
101 200 }, //Rookie 101-200 pts
    
201 300 }, //Good 201-300 pts
    
301 400 }, //Best 301-400 pts
    
401 999999999 //Pro 401+ pts
}

//This is used only to print/display the rank a player currently has.
new const RankNameRanks ][] = 
{
    
"Noob",
    
"Rookie",
    
"Good",
    
"Best",
    
"Pro"
}

//Create 2 arrays, g_XP[] is the number of XP points each player has;
//g_PlayerRank is the players current Rank (assigned by SetRank function)
new g_XP33 ] , Ranks:g_PlayerRank33 ];

public 
SetRankid 
{
    
//Loop through all of our ranks (See above enum)
    
for ( new Ranks:Noob <= Pro i++ )
    {
        
//Check if player is in current rank, suppose the player had 320 XP pts, this 
        //condition would be met at Pro rank since the XP range is 301-400. 
        // if ( 301 <= 320 <= 400 ) would be true so we assign Pro rank to player.
        
if ( RankXP][ ] <= g_XPid ] <= RankXP][ ] )
        {
            
g_PlayerRankid ] = i;
            break;
        }
    }

    
client_printprint_chat "XP=%d Rank=%s" g_XPid ] , RankNameg_PlayerRankid ] ] );  



SaM.ThE.MaN 06-12-2010 10:08

Re: Required_kills_for_next_level
 
i already have an xp mod kinda script.
I wanted some one to explain what Xella had done to add it to my script, Since in my script i already have levels and Xp for next level. I only wanna know how to show required xp.
I can give you the full script

Bugsy 06-12-2010 10:26

Re: Required_kills_for_next_level
 
PHP Code:

new const g_iRequiredKillsPerLevel[ ] = 
{
    
16,
    
32,
    
64,
    
128,
    
256
};

new 
g_iLevel33 ]; //Players current level
new g_iKills33 ]; //Players current # kills 
new g_iRequiredKills33 ]; //# kills needed for next level

//Example current kill#
g_iKillsid ] = 37;

//Keep looping while the kills are >= each kill level (range from 16-256). With each
//iteration, g_iLevel increases by 1 to change the required kill level we are checking.
//This loop would exit on the 3rd condition check leaving vals at: 
// g_iKills=37, g_iLevel=1, g_iRequiredKillsPerLevel=32
while( g_iKillsid ] >= g_iRequiredKillsPerLevelg_iLevelid ] ] )
{
    
/*Iterations
    1. g_iKills=37, g_iLevel=0, g_iRequiredKillsPerLevel=16
    2. g_iKills=37, g_iLevel=1, g_iRequiredKillsPerLevel=32 (loop exits here since 37 < 64)
    3. g_iKills=37, g_iLevel=2, g_iRequiredKillsPerLevel=64  */
    
g_iLevelid ]++;
}

//Here we determine the # kills needed for next level with these values:
// g_iLevel[ id ] = 1
// g_iLevel[ id ] + 1 = 2
// g_iRequiredKillsPerLevel[ 2 ] = 64
// g_iKills[ id ] = 37

// 27 = 64 - 37
g_iRequiredKillsid ] = g_iRequiredKillsPerLevelg_iLevelid ] + ] - g_iKillsid ]; 



All times are GMT -4. The time now is 05:25.

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