AlliedModders

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

zz870201 07-22-2014 09:13

Const problem
 
Code:

new const i_NormalWeapon[][] = {"","weapon_mp5navy","weapon_ak47"}
new const i_WeaponPrice[][] = {"","1000","300"}

public giveweaponmp5(id){
            give_item(id,i_NormalWeapon[1])
        new money = cs_get_user_money(id) - i_WeaponPrice[1][0]
        cs_set_user_money(id,money)
}

What wrong with it? I only spent 49$ for mp5....:shock:

mottzi 07-22-2014 09:21

Re: Const problem
 
First of all, you're using Strings where you should use Integer values. And thats why it takes 49 only, as '1' is 49 in the ASCII representation.

PHP Code:

new const i_NormalWeapon[][] = {"","weapon_mp5navy","weapon_ak47"}
new const 
i_WeaponPrice[] = {0,1000,300}

public 
giveweaponmp5(id){
        
give_item(id,i_NormalWeapon[1])
    new 
money cs_get_user_money(id) - i_WeaponPrice[1]
    
cs_set_user_money(id,money)


Why is the first element of both arrays empty anyways?

zz870201 07-22-2014 09:31

Re: Const problem
 
Quote:

Originally Posted by mottzi (Post 2171833)
First of all, you're using Strings where you should use Integer values. And thats why it takes 49 only, as '1' is 49 in the ASCII representation.

PHP Code:

new const i_NormalWeapon[][] = {"","weapon_mp5navy","weapon_ak47"}
new const 
i_WeaponPrice[] = {0,1000,300}

public 
giveweaponmp5(id){
        
give_item(id,i_NormalWeapon[1])
    new 
money cs_get_user_money(id) - i_WeaponPrice[1]
    
cs_set_user_money(id,money)


Why is the first element of both arrays empty anyways?

hahaha......
Ok thank you! :)


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

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