AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add entity in map (https://forums.alliedmods.net/showthread.php?t=104920)

Phant 09-29-2009 03:47

Add entity in map
 
Hello, i newbie in AMXX scripting, and i want to create plugin for add entity in special map.

Simple plan:
If current map = "de_dust2"
If Create Entity "cycler_sprite"
Add classname?
Add "origin" (coordinates)
Add "model" (sprites/*.spr)
Add "angles"
EndIf
EndIf

I try:
Code:

/* Script generated by Pawn Studio */

#include <amxmodx>
#include <fakemeta>

#define PLUGIN    "Add entity in map"
#define AUTHOR    "Phant"
#define VERSION    "1.0"

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    new s_Map[32];
    get_mapname(s_Map, charsmax(s_Map));
    if (equal(s_Map, "de_dust2"))
    {
        new entity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
            set_pev(entity, pev_classname, "cycler_sprite")
            set_pev(entity, pev_model, "sprites/3dmflaora.spr")
            set_pev(entity, pev_angles, "0, 90, 0")
            set_pev(entity, pev_origin, "197.0, 2190.0, -31")
    }

}

Don't work :(, can you show an example?
Thanks & sorry!

And question: where to get a compiler? I use this: http://www.amxmodx.org/webcompiler.cgi.

Arkshine 09-29-2009 05:58

Re: Add entity in map
 
Don't use info_target, use cycler_sprite as entity name and don't forget to spawn it ; dllfunc( DLLFunc_Spawn, entity )

Phant 11-10-2009 08:18

Re: Add entity in map
 
I added env_rain in de_dust2 map:
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "Snow"
#define VERSION "1.0"
#define AUTHOR "Phant"

public plugin_init(){
    register_plugin(PLUGIN, VERSION, AUTHOR)
   
    new mapid[32];
    get_mapname(mapid, charsmax(mapid))
   
    if(equal(mapid, "de_dust2"))
    {
        new ent_snow = create_entity("env_snow")
        entity_set_origin(ent_snow,Float:{-160.0,2000.0,-80.0})
    }
}

But it does not work, why? Maybe "plugin_init" lately called for creation rain?

Arkshine 11-10-2009 08:25

Re: Add entity in map
 
Try in plugin_precache()

xPaw 11-10-2009 08:32

Re: Add entity in map
 
Also you dont need to put origin for env_snow, it will be overall anyway.

Phant 11-11-2009 03:50

Re: Add entity in map
 
Quote:

Originally Posted by Arkshine (Post 985697)
Try in plugin_precache()

Thanks!
Quote:

Originally Posted by xPaw (Post 985701)
Also you dont need to put origin for env_snow, it will be overall anyway.

Ok, thanks, i thought that if entity without map border (in "space") — this error.

SnoW 11-11-2009 09:28

Re: Add entity in map
 
Quote:

Originally Posted by xPaw (Post 985701)
Also you dont need to put origin for env_snow, it will be overall anyway.

Hi.

Phant 11-14-2009 22:26

Re: Add entity in map
 
I successfully delete env_rain entity from de_aztec:
Code:

public plugin_init(){
 
  new mapid[32];
  get_mapname(mapid, charsmax(mapid))
 
  if(equal(mapid, "de_aztec"))
  {
      remove_entity_name("env_rain")
  }
}


But how to delete 5 ambient_generic from this map?
I try:
remove_entity_name("ambient_generic") — fail :shock:.

KadiR 11-15-2009 06:22

Re: Add entity in map
 
ambient_generic should work fine, and try also trigger_multiple, it makes the big thunder sound on the bridge and more..

xPaw 11-15-2009 06:27

Re: Add entity in map
 
Quote:

Originally Posted by Phant (Post 990157)

But how to delete 5 ambient_generic from this map?
I try:
remove_entity_name("ambient_generic") — fail :shock:.

Did you tryed in plugin_init? Because it will fail if you try in plugin_precache


All times are GMT -4. The time now is 22:41.

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