Raised This Month: $ Target: $400
 0% 

The code is correct?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zenok
New Member
Join Date: Aug 2010
Old 12-31-2011 , 08:12   The code is correct?
Reply With Quote #1

I'm starting with the programming of plugins and wanted to know if this is OK:

Code:
public donate(id,ammount,user)
{
//User ammo
new user1_ammo = zp_get_user_ammo_packs(id)
new user2_ammo = zp_get_user_ammo_packs(user)

if(user1_ammo >= ammount){
new user1_restar = user1_ammo-ammount
new user2_sumar = user2_ammo+ammount

zp_set_user_ammo_packs(id,user1_restar)
zp_set_user_ammo_packs(user,user2_sumar)

client_print(id, print_chat, "[ZP] "+ammont+" ammo give to "+user+"")
client_print(user, print_chat, "[ZP] Have you received "+ammont+" from "+id+"")
}else{
client_print(id, print_chat, "[ZP] You don't have enough Ammo Pack")
}

}

Last edited by zenok; 12-31-2011 at 08:15.
zenok is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 12-31-2011 , 08:33   Re: The code is correct?
Reply With Quote #2

PHP Code:
client_print(idprint_chat"[ZP] "+ammont+" ammo give to "+user+""
You can't format your string as in C++ / Java. Also, user is a id, not the name of the user.

http://www.amxmodx.org/funcwiki.php?go=func&id=49
http://www.amxmodx.org/funcwiki.php?go=func&id=165

user1_restar and user2_sumar are useless.

PHP Code:
new user1_restar user1_ammo-ammount
new user2_sumar user2_ammo+ammount

zp_set_user_ammo_packs
(id,user1_restar)
zp_set_user_ammo_packs(user,user2_sumar
->

PHP Code:
zp_set_user_ammo_packs(id,user1_ammo-ammount)
zp_set_user_ammo_packs(user,user2_ammo+ammount
__________________
micapat 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 06:09.


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