AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can i transfer xp with a command? (https://forums.alliedmods.net/showthread.php?t=183887)

Bilal Pro 04-28-2012 06:34

How can i transfer xp with a command?
 
Hello there,

I would like to know how i transfer xp from a command.

Example: xpmod_give_xp "Nickname/userid, ammount")

BeeFighter 04-28-2012 07:41

Re: How can i transfer xp with a command?
 
look @ exolents XP mod he got it:)

fysiks 04-28-2012 12:30

Re: How can i transfer xp with a command?
 
Simple:

Reduce user's xp by amount
Increase target user's xp by amount.

EpicMonkey 04-28-2012 12:43

Re: How can i transfer xp with a command?
 
Quote:

Originally Posted by fysiks (Post 1698154)
Simple:

Reduce user's xp by amount
Increase target user's xp by amount.

could it be any simpler ...

.Dare Devil. 04-28-2012 12:52

Re: How can i transfer xp with a command?
 
PHP Code:

public plugin_init ()
{
    
register_clcmd "xpmod_give_xp""transfer_xp")
}

public 
transfer_xp(id)
{  
    new 
name[32], xpamount[32], target
    
    read_argv
(1namecharsmax (name))
    
read_argv(2xpamountcharsmax (xpamount))
    
target cmd_target (idname3)
    
    if (!
target)
        return 
PLUGIN_HANDLED

    g_yourxpvariable
[target] = xpamount
    
return PLUGIN_HANDLED



fysiks 04-28-2012 13:01

Re: How can i transfer xp with a command?
 
Quote:

Originally Posted by .Dare Devil. (Post 1698166)
PHP Code:

public plugin_init ()
{
    
register_clcmd "xpmod_give_xp""transfer_xp")
}

public 
transfer_xp(id)
{  
    new 
name[32], xpamount[32], target
    
    read_argv
(1namecharsmax (name))
    
read_argv(2xpamountcharsmax (xpamount))
    
target cmd_target (idname3)
    
    if (!
target)
        return 
PLUGIN_HANDLED

    g_yourxpvariable
[target] = xpamount
    
return PLUGIN_HANDLED



That doesn't transfer xp. It just sets xp for the target. You need to check for number of arguments also.

Also, don't do it for him (especially when you do it wrong). This forum is called "Scripting Help" and not "Do This For Me Forum".

.Dare Devil. 04-28-2012 14:13

Re: How can i transfer xp with a command?
 
Quote:

Originally Posted by fysiks (Post 1698173)
That doesn't transfer xp. It just sets xp for the target. You need to check for number of arguments also.

Also, don't do it for him (especially when you do it wrong). This forum is called "Scripting Help" and not "Do This For Me Forum".

oh yeah, sorry.
i was on ohter world or something when i writed the code.

Did not readed the topic carefully.
anyway here it is!
PHP Code:

public plugin_init ()
{
    
register_clcmd "xpmod_give_xp""transfer_xp"// register that command 
}

public 
transfer_xp(id)
{  
    new 
name[32], xpamount[32], target
    
    read_argv
(1namecharsmax (name)) // get name from saytext arg " xpmod_give_xp [name] [] "
    
read_argv(2xpamountcharsmax (xpamount))  // get xpamount from saytext arg " xpmod_give_xp  [] [amount] "
    
target cmd_target (idname3// now get the target by the name what was in saytext arg
    
    
if (!target && g_yourxpvariable[id] > xpamount // check if there is a target and 
        
return PLUGIN_HANDLED    // check that transfer player have enough xp to sent it 

    
g_yourxpvariable[target] += xpamount // give xp to target
    
g_yourxpvariable[id] -= xpamount // take xp from transfer player
    
    
return PLUGIN_HANDLED


oh bytheway, and i explained what my code does this time, if you noticed.
It is very nice way to learn scripting, so i helped him with scripting.

mottzi 04-28-2012 14:50

Re: How can i transfer xp with a command?
 
Bilal Pro start brain.exe please.

Bilal Pro 04-28-2012 15:13

Re: How can i transfer xp with a command?
 
Quote:

Originally Posted by mottzi (Post 1698243)
Bilal Pro start brain.exe please.


Look at my join date, start eyes.exe please...

.Dare Devil. 04-28-2012 15:19

Re: How can i transfer xp with a command?
 
Quote:

Originally Posted by mottzi (Post 1698243)
Bilal Pro start brain.exe please.

Quote:

Originally Posted by Bilal Pro (Post 1698258)
Look at my join date, start eyes.exe please...

wtf :):):):)


All times are GMT -4. The time now is 07:50.

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