Raised This Month: $ Target: $400
 0% 

First Script Problem (Very Small)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-10-2005 , 07:39   First Script Problem (Very Small)
Reply With Quote #1

Basically what I want to do is give random equipment, and a certain ammount of it each round to all the players (maybe different to each player?).

THE PROBLEM NOW - Look at my bottom post for explaination.

Code:
#define AMX_MOD_X #include <amxmodx> #include <cstrike> #include <fun> #define MAX_LINES 64 #define MAX_STRING_LEN 256 new Title[32] = "Random Equip" new Version[32] = "0.0.0" new Author[16] = "TaRgEt*TuRkEy" new ammo_type new ammo_amount public plugin_init() {     register_plugin(Title,Version,Author)     register_logevent("new_round", 2, "1=Round_Start") } public new_round(id) {         new weapon[32]     new User[32]     new RandomNum = random(5) +1     if (RandomNum == 1)     {         ammo_type = 1         ammo_amount = 1         client_print(0,print_chat, "[AMX] <Random Equip> Your have recieved a complimentry P228!", User)     } else if (RandomNum == 2){         ammo_type = 3         ammo_amount = 1         client_print(0,print_chat, "[AMX] <Random Equip> Your have recieved a stunning Scout!", User)     } else if (RandomNum == 3){         ammo_type = 4         ammo_amount = 2         client_print(0,print_chat, "[AMX] <Random Equip> Your have recieved a 2 Hand Grenades!", User)     } else if (RandomNum == 4){         ammo_type = 5         ammo_amount = 1         client_print(0,print_chat, "[AMX] <Random Equip> Your have recieved a noobish XM1014!", User)     } else if (RandomNum == 5){         ammo_type = 7         ammo_amount = 1         client_print(0,print_chat, "[AMX] <Random Equip> Your have recieved an unaccurate Mac10!", User)     }     get_weaponname(ammo_type,weapon,sizeof(weapon))     give_item(id,weapon)     cs_set_user_bpammo(id,ammo_type,ammo_amount)     return PLUGIN_CONTINUE }
TaRgEt*TuRkEy is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-10-2005 , 15:19  
Reply With Quote #2

ammo_type and ammo_amount are defined in the heading of your script, but then you redefine them in new_round.

When you try to redefine them, you attempt to set their value to a function. The proper usage would be variable = str_to_num(stringhere), but there are no strings to convert to numbers in the first place.

Then, you try to set integers (ammo_type and ammo_amount) to a string ("1"). Just use 1.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-10-2005 , 18:41  
Reply With Quote #3

Alright It compiles properly now, but ingame is another story. This plugin goes crazy, it seems it runs round start sub like every .000001 seconds. Shouldn't it be only running once at round start? It's even running before anybody has joined. The exact debug targets the random function for a "stack" error. Thanks for your help.

NOTE: I updated script in first post to reflect newest.
TaRgEt*TuRkEy is offline
Timmi the savage
Senior Member
Join Date: Jul 2004
Location: seattle
Old 01-11-2005 , 10:28  
Reply With Quote #4

your gonna have to write the names in like this

new ammo[32]
ammo[] = "ammo_name"
Timmi the savage is offline
Send a message via Yahoo to Timmi the savage
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-11-2005 , 12:24  
Reply With Quote #5

Timmi, I don't see anywhere in the script where he would need to do that. Also, I have no idea why ResetHUD is being called so many times.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-11-2005 , 17:40  
Reply With Quote #6

The script works perfect except for it being called so many times over and over (until it eventually gives me an overflow). Any ideas how to fix would be nice.
TaRgEt*TuRkEy is offline
Da Bishop
Senior Member
Join Date: Aug 2004
Location: Chester County PA
Old 01-11-2005 , 18:06  
Reply With Quote #7

ResetHUD is called many times. How every many times its need to correct the HUD.. like time ammo etc. So you need to include something that will narrow it down a little. BTW using resetHUD for new round is bad anyways ;) EX.

Code:
register_logevent("new_round", 2, "1=Round_Start")
__________________
Anything that is done can only be done better by urself - since life is a opinion make it the way urs feel its best

~live by it
Da Bishop is offline
Send a message via MSN to Da Bishop
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-12-2005 , 00:22  
Reply With Quote #8

Alright compiles fine, and it displays the message random equip message too, the only thing, it doesn't give the equip. Here are the errors it gives me from ingame debugger:

Code:
L 01/11/2005 - 22:28:29: [AMXX] Native error in "give_item" on line 52 (file "randomequip.sma").
L 01/11/2005 - 22:28:29: [Fun] Player out of range (0)
L 01/11/2005 - 22:28:29: [AMXX] Native error in "cs_set_user_bpammo" on line 53 (file "randomequip.sma").
L 01/11/2005 - 22:28:29: [CStrike] Player out of range
I wonder what the problem is? I have all modules activated. And before when this script was buggy, it was actually giving me the weapons, just too many, so I wonder what's up now?
TaRgEt*TuRkEy is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 01-12-2005 , 09:33  
Reply With Quote #9

add a line before line 52 that is:

Code:
if(!is_user_connected(id)) return PLUGIN_CONTINUE
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-12-2005 , 15:06  
Reply With Quote #10

Okay then why isn't it detected when I or others are connected? I have tested with people, and it still isn't saying anybody is connected (not giving anybody anything)?

Is that a dedicated server only check? I am using listen.
TaRgEt*TuRkEy is offline
Reply


Thread Tools
Display Modes

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 19:16.


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