AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   'Defines' and 'if()' (https://forums.alliedmods.net/showthread.php?t=13276)

ZiP* 05-10-2005 08:55

'Defines' and 'if()'
 
I can't get this to work.


Code:
  #define invifrags 10 //set number of frags needed for invisibility  #define weapfrags 15 //set number of frags needed for weapon commands
I got those defines.
Now i want to use them like this:

Code:
if(get_user_team (id,slayer) && get_user_frags(weapfrags)) {     bla bla     client_print(id, print_chat, "*You need at least %s kills", weapfrags) }

And where the %s is, i want it to show the number i defined up there.

EDIT: forgot small tags :roll:

teame06 05-10-2005 09:44

Code:
new invifrags = 10 new weapfrags = 15 if(get_user_team (id,slayer) && get_user_frags(weapfrags)) {     bla bla     client_print(id, print_chat, "*You need at least %i kills", weapfrags) }

ZiP* 05-10-2005 10:05

Thank you. The frag-telling-thing works now.

Next question :o

How do i get the teams for IE. Vampire Slayer? I thought i could do like this:
Code:
new vampire, slayer if(get_user_team (id,vampire)) {      blah } if(get_user_team (id,slayer)) {      blah }

... That just doesn't work.

teame06 05-10-2005 11:04

what mod are you trying to write this for?

The code i just gave you is wrong.. So on every kill you want it to tell them you need xNumber of kills before you get blah.

ZiP* 05-10-2005 13:47

No. They should only get the number of kills they need if they're having under the limit.

I'm writing this for VS (Vampire Slayer). The problem is that it won't check the teams...

teame06 05-10-2005 16:28

the thing about get_user_team is you got to know what the constant for each team is. Once you know you can write the if statements for it. The thing is i don't know what you trying to do.

if you trying to catch this during a DeathMsg event.

Code:
// Store Killer index new kIndex = read_data(1) // Stores Victim index new vIndex = read_data(2) // Stores Killer Team index new kTeam = get_user_team(kIndex) // Stores victim Team Index new vTeam = get_user_team(id) // I don't know the constant for the teams in VS mod. So i'm just putting vampire or slayer if( kTeam == vampire) {      blah } else if( kTeam == slayer) {      blah } if( kTeam = vampire) {      blah } else if( vTeam == slayer) {      blah } // Till i know more i can't really help you.


Quote:

No. They should only get the number of kills they need if they're having under the limit.

I'm writing this for VS (Vampire Slayer). The problem is that it won't check the teams...
Not Understanding what you said here.

ZiP* 05-11-2005 10:25

ok...

-----------------------------------------------

I have two problems now.

1) it won't check which team the player is on. (tried yours, but i messed it up 8) just look...)
2) it doesn't make the player 100% invisible.

Code:
 #include   <amxmodx>  #include   <amxmisc>  #include   <fun>  new invifrags = 15 //set number of frags needed for invisibility  new weapfrags = 15 //set number of frags needed for weapon commands  public plugin_init()  {     register_plugin("VS Gameplay","0.1","ZiP*")     register_clcmd("say /ammo","weapon",ADMIN_USER,"all weapons")     register_clcmd("amx_invisible","invisible",ADMIN_USER,"invisibility")     register_clcmd("amx_visible","visible",ADMIN_USER,"visibility")  }    //WEAPON COMMANDS  public weapon(id)  {     new kIndex = read_data(1)     new kTeam = get_user_team(kIndex)         if(kTeam == 1 && get_user_frags(invifrags))     {         give_item(id,"weapon_vsstake") //Stake         give_item(id,"weapon_vsshotgun") // Shotgun         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsdbshotgun") //DBShotgun         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vscolt") // Stake + Colt         give_item(id,"weapon_vsmp5") // MP5         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscue") // Stake (cue)         give_item(id,"weapon_vsthunderfive") // Thunderfive         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         client_print(id, print_chat, "*You have been given ammo!")     } else {         client_print(id, print_chat, "*You need at least %i kills", weapfrags)     }     return PLUGIN_HANDLED  }  //INVISIBILITY  public invisible(id) {     new kIndex = read_data(1)     new kTeam = get_user_team(kIndex)         if(kTeam == 2 && get_user_frags(invifrags))     {         set_task(0.0,"glowinvis",id)         set_task(2.5,"invis",id)     } else {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED  }    //VISIBILITY  public visible(id) {     new kIndex = read_data(1)     new kTeam = get_user_team(kIndex)         if(kTeam == 2 && get_user_frags(invifrags))     {         set_task(0.0,"glowvis",id)         set_task(2.5,"vis",id)         return PLUGIN_HANDLED     } else {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED  }    //INVISIBILITY  public invis(id) {         set_user_rendering(id, kRenderFxPulseSlow,8,8,8,kRenderTransAlpha,0)     client_print(id, print_chat, "*You are Invisible!")     return PLUGIN_HANDLED  }    //VISIBILITY  public vis(id) {     set_user_rendering(id, kRenderFxPulseSlow,0,0,0,kRenderTransAlpha,255)     client_print(id, print_chat, "*You are Visible!")     return PLUGIN_HANDLED  }    //while getting invisible  public glowinvis(id) {     set_user_rendering(id,kRenderFxStrobeFast,255,130,19,kRenderNormal,25)     client_print(id, print_chat, "**Getting invisible!")     return PLUGIN_HANDLED  }    //while getting visible  public glowvis(id) {     set_user_rendering(id,kRenderFxPulseFast,200,19,130,kRenderNormal,25)     client_print(id, print_chat, "**Getting visible!")     return PLUGIN_HANDLED  }

Notice the team constants is 1 & 2, because i got errors with the others.

teame06 05-11-2005 11:34

Code:
#include    <amxmodx> #include    <amxmisc> #include    <fun> new invifrags = 15 //set number of frags needed for invisibility new weapfrags = 15 //set number of frags needed for weapon commands public plugin_init() {     register_plugin("VS Gameplay","0.1","ZiP*")     register_clcmd("say /ammo","weapon",ADMIN_USER,"all weapons")     register_clcmd("amx_invisible","invisible",ADMIN_USER,"invisibility")     register_clcmd("amx_visible","visible",ADMIN_USER,"visibility") } //WEAPON COMMANDS // Id is the index of the player when a client uses a command public weapon(id) {     new kTeam = get_user_team(id)     // When the command is ran it checks if they are on team constant 1 and then checks if player frag     // is greater or equal to weapon frags. Both must be true to give weapon.     if(kTeam == 1 && (get_user_frags(id) >= weapfrags))     {         give_item(id,"weapon_vsstake") //Stake         give_item(id,"weapon_vsshotgun") // Shotgun         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsdbshotgun") //DBShotgun         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vscolt") // Stake + Colt         give_item(id,"weapon_vsmp5") // MP5         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscue") // Stake (cue)         give_item(id,"weapon_vsthunderfive") // Thunderfive         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         client_print(id, print_chat, "*You have been given ammo!")     } else {         client_print(id, print_chat, "*You need at least %i kills", weapfrags)     }     return PLUGIN_HANDLED } //INVISIBILITY // Id is the index of the player that is use the command. public invisible(id) {     // get the player team from the id.     new kTeam = get_user_team(id)     if(kTeam == 2 && (get_user_frags(id) >= invifrags))     {         set_task(0.0,"glowinvis",id)         set_task(2.5,"invis",id)     } else {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } //VISIBILITY public visible(id) {     new kTeam = get_user_team(id)     if(kTeam == 2 && (get_user_frags(id) >= invifrags))     {         glowinvis(id) // if you use a set task 0 secs you can also do this.         set_task(2.5,"vis",id)         return PLUGIN_HANDLED     } else {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } //INVISIBILITY public invis(id) {     set_user_rendering(id, kRenderFxPulseSlow,8,8,8,kRenderTransAlpha,0)     client_print(id, print_chat, "*You are Invisible!")     return PLUGIN_HANDLED } //VISIBILITY public vis(id) {     set_user_rendering(id, kRenderFxPulseSlow,0,0,0,kRenderTransAlpha,255)     client_print(id, print_chat, "*You are Visible!")     return PLUGIN_HANDLED } //while getting invisible public glowinvis(id) {     set_user_rendering(id,kRenderFxStrobeFast,255,130,19,kRenderNormal,25)     client_print(id, print_chat, "**Getting invisible!")     return PLUGIN_HANDLED } //while getting visible public glowvis(id) {     set_user_rendering(id,kRenderFxPulseFast,200,19,130,kRenderNormal,25)     client_print(id, print_chat, "**Getting visible!")     return PLUGIN_HANDLED }

try this.

ZiP* 05-11-2005 13:16

Just tested it, here's what happened...

When i got 15 kills, it kept saying that i needed 15 kills, and also i would like it to say when you're on the wrong teams.

Slayers can't get invisible, vampires can't get weapons.

teame06 05-11-2005 14:05

Code:
#include    <amxmodx> #include    <amxmisc> #include    <fun> new invifrags = 15 //set number of frags needed for invisibility new weapfrags = 15 //set number of frags needed for weapon commands public plugin_init() {     register_plugin("VS Gameplay","0.1","ZiP*")     register_clcmd("say /ammo","weapon",ADMIN_USER,"all weapons")     register_clcmd("amx_invisible","invisible",ADMIN_USER,"invisibility")     register_clcmd("amx_visible","visible",ADMIN_USER,"visibility") } //WEAPON COMMANDS // Id is the index of the player when a client uses a command public weapon(id) {     new kTeam = get_user_team(id)     client_print(0, 3, "DEBUG: weapon Team %i", kTeam)     // When the command is ran it checks if they are on team constant 1 and then checks if player frag     // is greater or equal to weapon frags. Both must be true to give weapon.     if(kTeam == 1 && (get_user_frags(id) >= weapfrags))     {         give_item(id,"weapon_vsstake") //Stake         give_item(id,"weapon_vsshotgun") // Shotgun         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsshotgun")         give_item(id,"weapon_vsdbshotgun") //DBShotgun         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vsdbshotgun")         give_item(id,"weapon_vscolt") // Stake + Colt         give_item(id,"weapon_vsmp5") // MP5         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vsmp5")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscrossbow")         give_item(id,"weapon_vscue") // Stake (cue)         give_item(id,"weapon_vsthunderfive") // Thunderfive         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vsthunderfive")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         give_item(id,"weapon_vswinchester")         client_print(id, print_chat, "*You have been given ammo!")     } else if(kTeam == 1 && (get_user_frags(id) < weapfrags)) {         client_print(id, print_chat, "*You need at least %i kills", weapfrags)     }     return PLUGIN_HANDLED } //INVISIBILITY // Id is the index of the player that is use the command. public invisible(id) {     // get the player team from the id.     new kTeam = get_user_team(id)     client_print(0, 3, "DEBUG: invis Team %i", kTeam)     if(kTeam == 2 && (get_user_frags(id) >= invifrags))     {         set_task(0.0,"glowinvis",id)         set_task(2.5,"invis",id)     } else if(kTeam == 2 && (get_user_frags(id) < invifrags)) {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } //VISIBILITY public visible(id) {     new kTeam = get_user_team(id)     if(kTeam == 2 && (get_user_frags(id) >= invifrags))     {         set_task(0.0,"glowvis",id)         set_task(2.5,"vis",id)         return PLUGIN_HANDLED     } else {         client_print(id, print_chat, "*You need at least %i kills", invifrags)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } //INVISIBILITY public invis(id) {     set_user_rendering(id, kRenderFxPulseSlow,8,8,8,kRenderTransAlpha,0)     client_print(id, print_chat, "*You are Invisible!")     return PLUGIN_HANDLED } //VISIBILITY public vis(id) {     set_user_rendering(id, kRenderFxPulseSlow,0,0,0,kRenderTransAlpha,255)     client_print(id, print_chat, "*You are Visible!")     return PLUGIN_HANDLED } //while getting invisible public glowinvis(id) {     set_user_rendering(id,kRenderFxStrobeFast,255,130,19,kRenderNormal,25)     client_print(id, print_chat, "**Getting invisible!")     return PLUGIN_HANDLED } //while getting visible public glowvis(id) {     set_user_rendering(id,kRenderFxPulseFast,200,19,130,kRenderNormal,25)     client_print(id, print_chat, "**Getting visible!")     return PLUGIN_HANDLED }

client_print(0, 3, "DEBUG: weapon Team %i", kTeam)
client_print(0, 3, "DEBUG: invis Team %i", kTeam)

I have add this to both of the commands. See if the team constants are correct. Only reason it not working is because it not right constants for the teams. If you need any more help, just IM using one of my IM. I'll be working on a ATAC for NS.


Edit: ps also in NS mod get_user_team doesn't work i had to do a different way so for VS mod might has to be do the same thing.


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

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