AlliedModders

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

InteX01 03-08-2017 16:30

help
 
could somebody make me quickly simple plugin that gives +2000$ each round to player with M flag..

edon1337 03-08-2017 16:35

Re: help
 
Code:
#include <amxmodx> #include <cstrike> #include <hamsandwich> #define ADMIN_FLAG ADMIN_LEVEL_A public plugin_init() {     register_plugin("Money On Spawn", "1.0", "DoNii");     RegisterHam(Ham_Spawn, "player", "fw_HamSpawnPost", 1); } public fw_HamSpawnPost(id) {     if(!(is_user_alive(id) && get_user_flags(id) & ADMIN_FLAG))     return HAM_IGNORED;     cs_add_user_money(id, 2000);         return PLUGIN_CONTINUE; } cs_add_user_money(id, const amount) {     if(!is_user_connected(id))     return 0;     cs_set_user_money(id, cs_get_user_money(id) + amount);     return amount; }

EFFx 03-09-2017 07:41

Re: help
 
First of all

1. Your stock should not have a 'stock' prefix.
2. Why are you returning the ammount?

You don't need a stock. Just:

PHP Code:


public fw_HamSpawnPost(id)
{
    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_FLAG)
        
cs_set_user_money(idcs_get_user_money(id) + 2000)



edon1337 03-09-2017 07:44

Re: help
 
Quote:

Originally Posted by EFFx (Post 2502058)
First of all

1. Your stock should not have a 'stock' prefix.
2. Why are you returning the ammount?

You don't need a stock. Just:

PHP Code:


public fw_HamSpawnPost(id)
{
    if(
is_user_alive(id) && get_user_flags(id) & ADMIN_FLAG)
        
cs_set_user_money(idcs_get_user_money(id) + 2000)



1. It's a stock not a private function Sherlock.
2. It's just my choice.

My code is just fine. Also he never mentioned that user needs to be alive.

EFFx 03-09-2017 07:54

Re: help
 
I'm not a Sherlock, just tolding you whats correct.

1. Yes, its private, because It should be without.
2. Should have is_user_alive().

Wrong choice.

edon1337 03-09-2017 08:11

Re: help
 
Quote:

Originally Posted by EFFx (Post 2502061)
I'm not a Sherlock, just tolding you whats correct.

1. Yes, its private, because It should be without.

Wrong choice.

I wonder why fakemeta_util is full of stocks rather than private functions, or ham_[strip/give]_weapon :nono:.

EFFx 03-09-2017 08:20

Re: help
 
HamletEagle told me that. So I'm just saying what he said.

edon1337 03-09-2017 08:21

Re: help
 
Quote:

Originally Posted by EFFx (Post 2502071)
HamletEagle told me that. So I'm just saying what he said.

I'll wait and see what he will say :)

OciXCrom 03-09-2017 08:47

Re: help
 
Because fakemeta_util is a .inc file, you don't put all the things from it inside your code manually. The stock tag is used only in .inc file, because all the functions in it probably won't be used in the code. In your case, you are using the function, so you don't need the stock tag.

edon1337 03-09-2017 10:19

Re: help
 
Quote:

Originally Posted by OciXCrom (Post 2502084)
The stock tag is used only in .inc file, because all the functions in it probably won't be used in the code. In your case, you are using the function, so you don't need the stock tag.

https://forums.alliedmods.net/showthread.php?t=56377

Does that look like an include file to you?


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

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