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

give_item


Post New Thread Reply   
 
Thread Tools Display Modes
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 20:59   Re: give_item
Reply With Quote #11

We posted at same time
Phantom Warrior is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 21:05   Re: give_item
Reply With Quote #12

Okay.. you mean then my give_item should be in the "if"?

And how do i get that last death message..?

Edit:

Avalanche, i've tryed to put into a variable, but that ave me the same error too.

Last edited by stigma; 02-12-2007 at 21:50.
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 22:11   Re: give_item
Reply With Quote #13

Now, copy and paste the full code(With changes)
Phantom Warrior is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 22:19   Re: give_item
Reply With Quote #14

#include <amxmodx>
#include <fun>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

new time = get_gametime();
public plugin_init() {

register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("DeathMsg","giveItem","a")

}

public giveItem() {
new killer = read_data(1)
new victim = read_data(2)
new kName[32], vName[32]

get_user_name(killer,kName,31)
get_user_name(victim,vName,31)

client_print(0,print_chat,"Killer: %s - Victim: %s",kName,vName)
if (killer != victim) {
if (time < 0,2) {
give_item(killer,"weapon_hegrenade")
}
}
}
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 22:21   Re: give_item
Reply With Quote #15

Sorry for double posting, but if i edit in a post where there is some code it just fucks up..

But what i dont understand is the part with the lastDeathMsg[victim]
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-12-2007 , 23:16   Re: give_item
Reply With Quote #16

This is how I would implement it. Sorry if I messed up your formatting.

Code:
#include <amxmodx> #include <fun> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new Float:lastDeathMsg[33] // bugfix public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("DeathMsg","giveItem","a") } public giveItem() {     new killer = read_data(1)     new victim = read_data(2)     // bugfix     new Float:now = get_gametime()     if(lastDeathMsg[victim] - now < 0.2)         return;     lastDeathMsg[victim] = now     new kName[32], vName[32]     get_user_name(killer,kName,31)     get_user_name(victim,vName,31)     client_print(0,print_chat,"Killer: %s - Victim: %s",kName,vName)     if (killer != victim) {         give_item(killer,"weapon_hegrenade")     } }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 23:18   Re: give_item
Reply With Quote #17

Okay thanks alot.. But isent it necessary to use the {} when you make the if's?

And what was it the lastDeathMsg, was doing?
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-12-2007 , 23:46   Re: give_item
Reply With Quote #18

You only need to use curly braces {} if the "if" statement contains multiple lines of code to be executed. Since "return" is just one line of code, you don't need the braces. For example:

Code:
if(statement) line1 // line1 is executed if statement is true if(statement)    line1 // line1 is executed if statement is true if(statement)    line1 // line1 is executed if statement is true line2 // line2 is always executed, because there are no curly braces to group this with the if above, and it's not the first line after the if statement if(statement) {      line1 // line1 is executed if statement is true      line2 // line2 is executed if statement is true }

As for lastDeathMsg, what it is doing is recording at what time a player dies. Then, when a death message comes up, it compares that time with the time the death message was called. If this death message was called within 0.2 seconds of the last one, then it must be a glitchy death message from give_item, because no one naturally dies twice within 0.2 seconds.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 23:52   Re: give_item
Reply With Quote #19

Okay.. Thanks alot!
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
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 20:13.


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