Raised This Month: $51 Target: $400
 12% 

Hello, can someone help me?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sm1LeY
Junior Member
Join Date: Dec 2011
Old 01-14-2012 , 04:19   Hello, can someone help me?
Reply With Quote #1

I start to learn coding yesterday, and i want to make my first plugin, but compiler write some errors, can someone help me repair it?

CODE:
Code:
#include <amxmodx>
#include <cstrike>
#include <fun>


public plugin_init() {
	
	register_plugin("give", "1.0", "scream")
	register_clcmd("say /dgl", "dgl")
	register_clcmd("say /m4", "m4")
	register_clcmd("say /ak47", "ak47")
	register_clcmd("say /awp", "awp")
	register_clcmd("say /c4", "c4")
}

public dgl (id)
{ 
	cs_set_weapon_ammo (id, give_item (id, "weapon_deagle") 250)
	cs_set_user_money (id, cs_get_user_money (id) - 1200)
}

public m4 (id)
{
	cs_set_weapon_ammo (id, give_item (id, "weapon_m4a1") 250)
	cs_set_user_money (id, cs_get_user_money (id) - 2500)
}

public ak47 (id)
{
	cs_set_weapon_ammo (id, give_item (id, "weapon_ak47") 250)
	cs_set_user_money (id, cs_get_user_money (id) -2500)
}

public awp (id)
{
	cs_set_weapon_ammo (id, give_item (id, "weapon_awp") 250)
	cs_set_user_money (id, cs_get_user_money (id) -3000)
}

public c4 (id)
{
	cs_set_weapon_ammo (id, give_item (id, "weapon_c4") 1)
	cs_set_user_money (id, cs_get_user_money (id) -0)
}
Code:
AND HERE IS ERRORS:  1.  Error: Expected token: ",", but found "-integer value-" on line 25
                     2.  Warning: Expression has no effect on line 25
                     3.  Error: Expected token: ";", but found ")" on line 25
                     4.  Error: Invalid expression, assumed zero on line 25
                     5.  Error: Too many error messages on one line on line 25
Sm1LeY is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-14-2012 , 04:23   Re: Hello, can someone help me?
Reply With Quote #2

PHP Code:
cs_set_user_money (idcs_get_user_money (id) - 2500

PHP Code:
cs_set_user_money (idcs_get_user_money (id) -2500
EDIT: Or you can do
PHP Code:
#define fm_get_user_money(%1)    get_pdata_int( %1, 115 )


new money fm_get_user_money(id);
    new 
cost 2500
    
if(money cost || money == cost
    {
        
fm_set_user_money(idmoney cost);

public 
fm_set_user_money indexi_Money ) { 
    
set_pdata_int index115i_Money ); 

    
message_begin MSG_ONEg_msgMoney_index ); 
    
write_long i_Money ); 
    
write_byte ); 
    
message_end (); 

__________________

Last edited by Ex1ne; 01-14-2012 at 04:27.
Ex1ne is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-14-2012 , 04:28   Re: Hello, can someone help me?
Reply With Quote #3

cs_set_weapon_ammo (id, give_item (id, "weapon_deagle") 250)

->

cs_set_weapon_ammo (id, give_item (id, "weapon_deagle"), 250)

Error for all cs_set_weapon_ammo natives.

Also, you should do something like

Code:
new iDeagle = give_item( id , "weapon_deagle" ) cs_set_weapon_ammo( iDeagle , 1 ) // note that is for the ammo IN the weapon // if you want to set the bpammo to 35 (ammo to reload) you should use this : cs_set_user_bpammo( id , CSW_DEAGLE , 35 )

cs_set_user_money (id, cs_get_user_money (id) -0)

This is useless.

Moreover, I think you can't add ammo to "weapon_c4", so :

cs_set_weapon_ammo (id, give_item (id, "weapon_c4") 1)

->

PHP Code:
give_itemid "weapon_c4" 
You should check if he doesn't already have a c4 too.

EDIT :

Quote:
Originally Posted by Ex1ne View Post
PHP Code:
cs_set_user_money (idcs_get_user_money (id) - 2500

PHP Code:
cs_set_user_money (idcs_get_user_money (id) -2500
What is the difference ?

Quote:
Originally Posted by Ex1ne View Post
EDIT: Or you can do
PHP Code:
if(money cost || money == cost
This is the same as if( money >= cost ) with 1 less check.
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 01-14-2012 at 11:14.
Devil259 is offline
Sm1LeY
Junior Member
Join Date: Dec 2011
Old 01-14-2012 , 04:47   Re: Hello, can someone help me?
Reply With Quote #4

thanks a lot
Sm1LeY is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-14-2012 , 05:04   Re: Hello, can someone help me?
Reply With Quote #5

Don't forget to use the funcwiki and see in plugins when you need help. There is a lot of tutorials here too.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
fLaXXiE.
Member
Join Date: Jan 2012
Old 01-14-2012 , 05:06   Re: Hello, can someone help me?
Reply With Quote #6

Problem is now fixed fully! - Here ya' go.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>

public plugin_init() 
{
 
register_plugin("giv weapone""1.0""scream")
 
register_clcmd("say /dgl""dgl")
 
register_clcmd("say /m4""m4")
 
register_clcmd("say /ak47""ak47")
 
register_clcmd("say /awp""awp")
 
register_clcmd("say /c4""c4")
}

public 
dgl (id)

 
cs_set_user_bpammoid CSW_DEAGLE 35 )
 
cs_set_user_money (idcs_get_user_money (id) -1200)
}

public 
m4 (id)
{
 
cs_set_user_bpammoid CSW_M4A1 90 )
 
cs_set_user_money (idcs_get_user_money (id) -2500)
}

public 
ak47 (id)
{
 
cs_set_user_bpammoid CSW_AK47 90 )
 
cs_set_user_money (idcs_get_user_money (id) -2500)
}

public 
awp (id)
{
 
cs_set_user_bpammoid CSW_AWP 30 )
 
cs_set_user_money (idcs_get_user_money (id) -3000)
}

public 
c4 (id)
{
 
cs_set_user_bpammoid CSW_C4 )
 
cs_set_user_money (idcs_get_user_money (id) -0)

__________________
Currently working public plugins; Will be released, stop asking!
PM me for private work; i will look your message when i have time.

Public plugins by me:
Achievements ( 100% )
Jailbreak Glow Menu ( 100% )
fLaXXiE. is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-14-2012 , 05:08   Re: Hello, can someone help me?
Reply With Quote #7

Did you read what I said ?
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Sm1LeY
Junior Member
Join Date: Dec 2011
Old 01-14-2012 , 05:15   Re: Hello, can someone help me?
Reply With Quote #8

thakns a lot, i read tutorials from allied forum and from one czech web.

Last edited by Sm1LeY; 01-14-2012 at 05:16.
Sm1LeY is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 01-14-2012 , 07:49   Re: Hello, can someone help me?
Reply With Quote #9

Quote:
Originally Posted by Devil259 View Post
Did you read what I said ?
Clearly not.


Quote:
Originally Posted by Devil259 View Post
cs_set_weapon_ammo (id, give_item (id, "weapon_deagle") 250)

->

cs_set_weapon_ammo (id, give_item (id, "weapon_deagle"), 250)
Fyi
Quote:
Syntax:

cs_set_weapon_ammo ( index, newammo )
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 01-14-2012 at 07:50.
hornet is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-14-2012 , 11:14   Re: Hello, can someone help me?
Reply With Quote #10

Quote:
Originally Posted by hornet View Post
Fyi
My bad, fixed.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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