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

Solved [Maps ] Spawn Bosses


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 06-20-2020 , 13:22   [Maps ] Spawn Bosses
Reply With Quote #1

There are 3 Bosses ( loading all 3 plugins on the NPC Mod )
I do spawn on the map in precache in each plugin like this

boss_alien
PHP Code:
    if(equal(mapname"Alien") != -1)
    {
        
y_spawn_points[0] = 138.0
        y_spawn_points
[1] = -263.0 
        y_spawn_points
[2] = 36.0 
    

boss_revenant
PHP Code:
    if(equal(mapname"Revenant") != -1)
    {
        
y_spawn_points[0] = 243.0
        y_spawn_points
[1] = 109.0 
        y_spawn_points
[2] = -412.0
    

boss_titan
PHP Code:
    if(equal(mapname"Titan") != -1)            
    {
        
y_spawn_points[0] = -431.0
        y_spawn_points
[1] = -33.0 
        y_spawn_points
[2] = 613.0
    

And for some reason on the map Alien spawn in addition to the other 2 Bosses

Tell me, what other way is there for only one Boss to work on a specific map ( 1 plugin )

Last edited by MayroN; 06-22-2020 at 20:23.
MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-20-2020 , 13:50   Re: [Maps ] Spawn Bosses
Reply With Quote #2

When do you want to spawn bosses, on each player spawn?
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-20-2020 , 14:03   Re: [Maps ] Spawn Bosses
Reply With Quote #3

I didn't really get enough info, but this might be what you want:

PHP Code:
public plugin_init()
{
    new 
g_mapname[40];
    
get_mapname(g_mapname39);

PHP Code:
    if(g_mapname)
    {
        switch(
g_mapname)
        {
            case 
Alien:  //map name
            
{
                
y_spawn_points[0] = 138.0 //code
                
y_spawn_points[1] = -263.0 
                y_spawn_points
[2] = 36.0 
            
}
            case 
Revenant:
            {
                
y_spawn_points[0] = 243.0
                y_spawn_points
[1] = 109.0 
                y_spawn_points
[2] = -412.0
            
}
            case 
Titan:
            {
                
y_spawn_points[0] = -431.0
                y_spawn_points
[1] = -33.0 
                y_spawn_points
[2] = 613.0
            
}
        }
    } 
__________________
Contact! || Discord:
Mr_Boopsy_#2066

Last edited by supertrio17; 06-20-2020 at 14:03.
supertrio17 is offline
Old 06-20-2020, 14:45
ZaX
This message has been deleted by ZaX. Reason: my bad, nvm
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-20-2020 , 19:23   Re: [Maps ] Spawn Bosses
Reply With Quote #4

That's happening because you're checking if the value returned by the function "equal" is not -1. It will always be true since "equal" returns true (1) or false (0). To fix that just switch != -1 for != 0

For more info on "equal" function check this
__________________









Last edited by CrazY.; 06-20-2020 at 19:25.
CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-21-2020 , 03:04   Re: [Maps ] Spawn Bosses
Reply With Quote #5

Quote:
Originally Posted by supertrio17 View Post
I didn't really get enough info, but this might be what you want:

PHP Code:
public plugin_init()
{
    new 
g_mapname[40];
    
get_mapname(g_mapname39);

PHP Code:
    if(g_mapname)
    {
        switch(
g_mapname)
        {
            case 
Alien:  //map name
            
{
                
y_spawn_points[0] = 138.0 //code
                
y_spawn_points[1] = -263.0 
                y_spawn_points
[2] = 36.0 
            
}
            case 
Revenant:
            {
                
y_spawn_points[0] = 243.0
                y_spawn_points
[1] = 109.0 
                y_spawn_points
[2] = -412.0
            
}
            case 
Titan:
            {
                
y_spawn_points[0] = -431.0
                y_spawn_points
[1] = -33.0 
                y_spawn_points
[2] = 613.0
            
}
        }
    } 
switch cannot be used with strings and even if it worked, Alien/Revenant are not strings.
__________________
HamletEagle is offline
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 06-21-2020 , 03:15   Re: [Maps ] Spawn Bosses
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
That's happening because you're checking if the value returned by the function "equal" is not -1. It will always be true since "equal" returns true (1) or false (0). To fix that just switch != -1 for != 0

For more info on "equal" function check this
Strangely, it didn't work
MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 06-21-2020 , 06:28   Re: [Maps ] Spawn Bosses
Reply With Quote #7

@MayroN
how did you hook maps name?
I don't see maps with those names (Alien, Revenant ...)
Show us the function code or full code to make it easier to find out the problem
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-21-2020 , 07:06   Re: [Maps ] Spawn Bosses
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
switch cannot be used with strings and even if it worked, Alien/Revenant are not strings.
I tried it with a mapname and it did work.
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-21-2020 , 07:20   Re: [Maps ] Spawn Bosses
Reply With Quote #9

Quote:
Originally Posted by supertrio17 View Post
I tried it with a mapname and it did work.
You didn't, as your code does not even compile.

if(g_mapname) is wrong because g_mapname is an array, you probably meant g_mapname[0](to check if the string is not empty).
switch(g_mapname) switch cannot be used on strings.
case Alien: Alien is not a string, "Alien" is(unless you defined somewhere new Allien[] = "Alien", which you probably did not, and if you did you should have posted this in your answer). Alien, as you used it in your code, is an unknown symbol and will produce a compilation error.
Regardless, the code you posted will not compile because of issues 1 and 2 anyway.

A simple test plugin:
PHP Code:
#include <amxmodx>

public plugin_init()
{
    new array[
32]
    if(array)
    {
        switch(array)
        {
            case 
"aaa"
            {
            }
            case 
"bbb":
            {
            }
        }
    }

Can you compile it? You can't because it is not valid.

Please test your code before posting and trying to help others so you don't end up confusing them instead.
__________________

Last edited by HamletEagle; 06-21-2020 at 07:21.
HamletEagle is offline
Foxa
Member
Join Date: Nov 2018
Location: Croatia
Old 06-21-2020 , 08:19   Re: [Maps ] Spawn Bosses
Reply With Quote #10

What are the exact map names? I'm pretty sure that there aren't maps named "Alien", "Revenant" and "Titan"..
Maybe "boss_alien", "boss_revenant" and "boss_titan"??
Also how are you getting the "mapname"?
Foxa 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 17:17.


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