AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] Need help with code (https://forums.alliedmods.net/showthread.php?t=251703)

popeye10 11-17-2014 16:29

[Help] Need help with code
 
i want
when victim frag 0
killer not take him frags
PHP Code:

set_user_frags(killerget_user_frags(killer) + amount);
set_user_frags(victimget_user_frags(victim) - amount); 


Jhob94 11-17-2014 16:36

Re: [Help] Need help with code
 
Quote:

Originally Posted by popeye10 (Post 2225465)
i want
when victim frag 0
killer not take him frags
PHP Code:

set_user_frags(killerget_user_frags(killer) + amount);
set_user_frags(victimget_user_frags(victim) - amount); 


if(!get_user_frags(victim)) return PLUGIN_HANDLED

fysiks 11-17-2014 19:22

Re: [Help] Need help with code
 
Quote:

Originally Posted by Jhob94 (Post 2225469)
if(!get_user_frags(victim)) return PLUGIN_HANDLED

And how is that advice helpful?

zmd94 11-18-2014 00:45

Re: [Help] Need help with code
 
Maybe, this can help.
PHP Code:

if(get_user_frags(isVictim))
{
    
set_user_frags(isAttackerget_user_frags(isAttacker) + iAmount)
    
set_user_frags(isVictimget_user_frags(isVictim) - iAmount)



Jhob94 11-18-2014 04:08

Re: [Help] Need help with code
 
Quote:

Originally Posted by fysiks (Post 2225501)
And how is that advice helpful?

You don't know read? He asked how to check if user has not frags, so i told him.. How is your reply helpful?

popeye10 11-18-2014 04:08

Re: [Help] Need help with code
 
Quote:

Originally Posted by zmd94 (Post 2225553)
Maybe, this can help.
PHP Code:

// If only if the victim frag is more than "0"
if(get_user_frags(isVictim) >= 0)
{
    
set_user_frags(isAttackerget_user_frags(isAttacker) + iAmount)
    
set_user_frags(isVictimget_user_frags(isVictim) - iAmount)



thanx zmd94 it' work

Jhob94 11-18-2014 04:12

Re: [Help] Need help with code
 
Its useless to do checks if is higher than 0, you just need:
PHP Code:

if(get_user_frags(isVictim)) 

    
set_user_frags(isAttackerget_user_frags(isAttacker) + iAmount
    
set_user_frags(isVictimget_user_frags(isVictim) - iAmount


Anyway if you check if frags = 0, then it will also affect when frags are 0.

zmd94 11-18-2014 04:19

Re: [Help] Need help with code
 
My fault, Jhob94.

I have updated the code. ;)

Jhob94 11-18-2014 04:27

Re: [Help] Need help with code
 
Quote:

Originally Posted by zmd94 (Post 2225590)
My fault, Jhob94. I have updated the code.

Man :grrr:
You forgot the wink :twisted:

fysiks 11-18-2014 19:26

Re: [Help] Need help with code
 
Quote:

Originally Posted by Jhob94 (Post 2225587)
You don't know read? He asked how to check if user has not frags, so i told him.. How is your reply helpful?

I didn't find your post helpful because your code was given without any context. It's useless without context because you don't know where in his code he wants the functionality. Returning in a random place doesn't generally do any good unless you know all the code that exists in the function.


All times are GMT -4. The time now is 17:31.

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