AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [Maps ] Spawn Bosses (https://forums.alliedmods.net/showthread.php?t=325398)

MayroN 06-20-2020 13:22

[Maps ] Spawn Bosses
 
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 )

supertrio17 06-20-2020 13:50

Re: [Maps ] Spawn Bosses
 
When do you want to spawn bosses, on each player spawn?

supertrio17 06-20-2020 14:03

Re: [Maps ] Spawn Bosses
 
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
            
}
        }
    } 


CrazY. 06-20-2020 19:23

Re: [Maps ] Spawn Bosses
 
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

HamletEagle 06-21-2020 03:04

Re: [Maps ] Spawn Bosses
 
Quote:

Originally Posted by supertrio17 (Post 2706576)
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.

MayroN 06-21-2020 03:15

Re: [Maps ] Spawn Bosses
 
Quote:

Originally Posted by CrazY. (Post 2706619)
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 :(

abdobiskra 06-21-2020 06:28

Re: [Maps ] Spawn Bosses
 
@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

supertrio17 06-21-2020 07:06

Re: [Maps ] Spawn Bosses
 
Quote:

Originally Posted by HamletEagle (Post 2706657)
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.

HamletEagle 06-21-2020 07:20

Re: [Maps ] Spawn Bosses
 
Quote:

Originally Posted by supertrio17 (Post 2706682)
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.

Foxa 06-21-2020 08:19

Re: [Maps ] Spawn Bosses
 
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"?


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

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