AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How to do that once an added exp (https://forums.alliedmods.net/showthread.php?t=252475)

Forever Killer 12-03-2014 13:08

[HELP] How to do that once an added exp
 
Hi, in first of my help thread i want to sorry all for my english... ;D

My trouble is, in plugin i writing to cod mod and i can't set that add experience just one time...
Now experience added all of time, and this is my problem.. I want to do that once an added exp..

How it is to operate:
I have two kills i gets 'Elo' rank and just random from 0-30 exp gives to me just once time... If i have two kills...

Code of plugin:
Code:

#include <amxmodx>
#include <amxmisc>
#include <csx>
#include <codmod>
#include <colorchat>

#define PLUGIN "EXP for ranks"
#define VERSION "1.0"
#define AUTHOR "Forever Killer "

#define TASK 666

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
}

public client_connect(id)
{
    if(is_user_bot(id))
        return
 
    new param[1]
    param[0] = id
 
    set_task(1.0,"rank",TASK+id,param,1,"b")
}
public client_disconnect(id)
    if(task_exists(TASK+id))
    remove_task(TASK+id)

public rank(param[])
{
    new id = param[0]
        new exp = cod_get_user_xp(id);
 
    static stats[8], body[8]
    get_user_stats(id, stats, body)
 
    new ranga[30]       
 
    if ( stats[0] >= 0 && stats[0] <= 2) format(ranga,29,"Elo")
        if ( stats[0] >= 3 && stats[0] <= 4) format(ranga,29,"Starter")
        {
        new losowy = random(30);
        cod_set_user_xp(id, exp+losowy);
        ColorChat(id, GREEN, "^x01Gives %i ^x01EXP for rank %s", losowy, ranga);
        }

    set_hudmessage(255, 255, 255, 0.15, 0.55)
    show_hudmessage(id, "Frags: %d^nRank: %s",stats[0], ranga)

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1250\\ deff0\\ deflang1045{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/

Somebody can help me? If u don't understand my english just ask.. I will try to clarify...

zmd94 12-03-2014 19:42

Re: [HELP] How to do that once an added exp
 
What this code mean?
PHP Code:

        if ( stats[0] >= && stats[0] <= 2format(ranga,29,"Elo")
        if ( 
stats[0] >= && stats[0] <= 4)  format(ranga,29,"Starter"

So, you want to have a permanent hud that will show player frag and position?

Next, you also want to give free experiences just once for "Elo" level?

Forever Killer 12-04-2014 09:11

Re: [HELP] How to do that once an added exp
 
zmd94, Yeah.. exactly yes.

zmd94 12-04-2014 10:55

Re: [HELP] How to do that once an added exp
 
Actually, what are you trying to do with below code? Please explain about this code first.
PHP Code:

        if ( stats[0] >= && stats[0] <= 2format(ranga,29,"Elo")
        if ( 
stats[0] >= && stats[0] <= 4)  format(ranga,29,"Starter"


Forever Killer 12-04-2014 11:17

Re: [HELP] How to do that once an added exp
 
if ( stats[0] >= 0 && stats[0] <= 2) format(ranga,29,"Elo")
if ( stats[0] >= 3 && stats[0] <= 4) format(ranga,29,"Starter")

This code using statsx.amxx So

stats[0] it's save from statsx....

And.. If stats kills >= 0 kills and stats kills <= 2 kills give rank 'Elo' and add once time random 0-30 experience . :)

zmd94 12-04-2014 11:26

Re: [HELP] How to do that once an added exp
 
So, you will only have two positions which are "Elo" and "Starter"?

Forever Killer 12-04-2014 13:11

Re: [HELP] How to do that once an added exp
 
No I want add my own position.. But this after ...

zmd94 12-04-2014 23:11

Re: [HELP] How to do that once an added exp
 
Just try below. ;)
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <codmod>
#include <csx>

#define TASK_RESET 1666

new iPosition[33]

public 
plugin_init() 
{
    
register_plugin("""1.0""")
    
    
register_event("DeathMsg""event_DeathMsg""a""1>0")
}

public 
client_putinserver(id)
{
    if(
is_user_connected(id) && !is_user_bot(id))
    {    
        
set_task(1.0"iHud"id+TASK_RESET__"b")
    }
}

public 
client_disconnect(id)
{
    
remove_task(id+TASK_RESET)
}

public 
iHud(id)
{
    
id -= TASK_RESET
    
if(is_user_alive(id))
    {
        static 
iStats[8], iBody[8]
        
get_user_stats(idiStatsiBody)

        
set_hudmessage(2552552550.150.55)
        
show_hudmessage(id"Frags: %d^nPosition: %s"iStats[0], iPosition)
    }
}  

public 
event_DeathMsg()
{
    new 
iAttaciAttac read_data(1)
    new 
iVictimiVictim read_data(2)
    
    if(
iVictim == iAttac || !is_user_alive(iAttac))
        return
    
    static 
iStats[8], iBody[8]
    
get_user_stats(iAttaciStatsiBody)
    
    new 
iEXP cod_get_user_xp(iAttac)
    new 
iFree random_num(130)
    
    switch(
iStats[0])
    {
        
// If the player has 2 frags. If you want to configure to 6, just change
        // number 2 to 6 and so on. ;)
        
case 2:
        {
            
// Configure the position
            
format(iPositioncharsmax(iPosition), "Elo")
            
            
// Free EXP
            
cod_set_user_xp(iAttaciEXP iFree);
            
            
// Print the message
            
ColorChat(iAttacGREEN"^x01Free %i ^x01EXP for position %s"iFreeiPosition)
        }
        
// If the player has 4 frags.
        
case 4:
        {
            
format(iPositioncharsmax(iPosition), "Starter")
            
            
// Just continue. ;)
        
}
        
// Just continue. ;)
    
}



Forever Killer 12-05-2014 15:39

Re: [HELP] How to do that once an added exp
 
Quote:

Originally Posted by zmd94 (Post 2231325)
Just try below. ;)
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <codmod>
#include <csx>

#define TASK_RESET 1666

new iPosition[33]

public 
plugin_init() 
{
    
register_plugin("""1.0""")
    
    
register_event("DeathMsg""event_DeathMsg""a""1>0")
}

public 
client_putinserver(id)
{
    if(
is_user_connected(id) && !is_user_bot(id))
    {    
        
set_task(1.0"iHud"id+TASK_RESET__"b")
    }
}

public 
client_disconnect(id)
{
    
remove_task(id+TASK_RESET)
}

public 
iHud(id)
{
    
id -= TASK_RESET
    
if(is_user_alive(id))
    {
        static 
iStats[8], iBody[8]
        
get_user_stats(idiStatsiBody)

        
set_hudmessage(2552552550.150.55)
        
show_hudmessage(id"Frags: %d^nPosition: %s"iStats[0], iPosition)
    }
}  

public 
event_DeathMsg()
{
    new 
iAttaciAttac read_data(1)
    new 
iVictimiVictim read_data(2)
    
    if(
iVictim == Attac || !is_user_alive(Attac))
        return
    
    static 
iStats[8], iBody[8]
    
get_user_stats(AttaciStatsiBody)
    
    new 
iEXP cod_get_user_xp(Attac)
    new 
iFree random_num(130)
    
    switch(
iStats[0])
    {
        
// If the player has 2 frags. If you want to configure to 6, just change
        // number 2 to 6 and so on. ;)
        
case 2:
        {
            
// Configure the position
            
format(iPositioncharsmax(iPosition), "Elo")
            
            
// Free EXP
            
cod_set_user_xp(AttaciEXP iFree);
            
            
// Print the message
            
ColorChat(AttacGREEN"^x01Free %i ^x01EXP for position %s"iFreeiPosition)
        }
        
// If the player has 4 frags.
        
case 4:
        {
            
format(iPositioncharsmax(iPosition), "Starter")
            
            
// Just continue. ;)
        
}
        
// Just continue. ;)
    
}



Code:

abec.sma(49) : error 017: undefined symbol "Attac"
abec.sma(53) : error 017: undefined symbol "Attac"
abec.sma(53) : warning 215: expression has no effect
abec.sma(53) : warning 215: expression has no effect
abec.sma(53) : error 001: expected token: ";", but found ")"
abec.sma(53) : error 029: invalid expression, assumed zero
abec.sma(53) : fatal error 107: too many error messages on one line

Many errors.. : /. Not compiled..

zmd94 12-05-2014 20:16

Re: [HELP] How to do that once an added exp
 
I have updated the code.


All times are GMT -4. The time now is 15:27.

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