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

Put A Sprite In The Userīs Origin


Post New Thread Reply   
 
Thread Tools Display Modes
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 09-03-2010 , 10:31   Re: Put A Sprite In The Userīs Origin
Reply With Quote #21

Quote:
Originally Posted by Hunter-Digital View Post
You really have no ideea what you are doing there.
Not much, but you are teaching me a lot (i think)

============================================= ========================

Quote:
portal_touch() for is called by register_touch() wich sends the toucher and touched entities (in your case the portal entity number and the player's entity number) and of course it sends you to 0 0 0 because "exOrigin" is not filled by anything.
Yeah, now i understand this part, but why exOrigin is not filled if in this part i fill it:
PHP Code:
new exOrigin[3]

   
get_user_origin(idexOrigin
But itīs wrong, i think that in the touch i should get the portal origin, but i donīt know how to do this

EDIT: At last iīve done somethig myself ^^! i fill the coordinates variable using this
PHP Code:
public portal_touch(entid)
{
    new 
FloatfTeleportOrigin[3]
    
entity_get_vector(entEV_VEC_originfTeleportOrigin)
    new 
iTeleportOrigin[3]
    
FVecIVec(fTeleportOriginiTeleportOrigin)
    
    if(!Exit)
    {
        
client_print(idprint_center"Create A Exit Portal First")
    }
    else
    {
    
set_user_origin(idiTeleportOrigin)
    
client_print(id,print_center,"You have been teleported")
    }

But is not done, this get the origin of the portal entrance and, if i put this code in the exit portal creation and if I add iTeleportOrigin[3] to the param of the touch doesnīt work

If i put in the param:
PHP Code:
public portal_touchiTeleportOrigin[3], entid
Nothing happens when i touch the portal
PHP Code:
public portal_touch(ent,  iTeleportOrigin[3], id
Teleport to 0 0 0
PHP Code:
public portal_touch(entidiTeleportOrigin[3]) 
Nothing happens when i touch the portal

Portal Exit Creation:
PHP Code:
public create_portal2(exOrigin[3], id)
{
   new 
Float:fOrigin[3]
   
   new 
ent create_entity("env_sprite")

   
IVecFVec(exOriginfOrigin)

   
entity_set_string(entEV_SZ_classname"portal_exit")
   
entity_set_model(ent"sprites/e-tele1.spr")
   
entity_set_int(entEV_INT_spawnflagsSF_SPRITE_STARTON)
   
entity_set_float(entEV_FL_framerate30.0)

   
DispatchSpawn(ent)

   
entity_set_origin(entfOrigin)
   
entity_set_size(entFloat:{-25.0, -25.0, -25.0}, Float:{25.025.025.0})
   
entity_set_int(entEV_INT_solidSOLID_TRIGGER)
   
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY)
   
entity_set_int(entEV_INT_rendermodekRenderTransAdd)
   
entity_set_float(entEV_FL_renderamt255.0)
   
entity_set_float(entEV_FL_scale1.0)

   
client_print(0print_chat"%d created portal (%d)"ident)
   Exit = 
true
   
   
new FloatfTeleportOrigin[3]
   
entity_get_vector(entEV_VEC_originfTeleportOrigin)
   new 
iTeleportOrigin[3]
   
FVecIVec(fTeleportOriginiTeleportOrigin)

If I make a task:
PHP Code:
    set_task(0.1"Teleport"idiTeleportOrigin3)
    
client_print(id,print_center,"You have been teleported")
    }
}
public 
Teleport(idiTeleportOrigin[3])
{
    
set_user_origin(idiTeleportOrigin)
    
client_print(idprint_chat"Teleported..")

The console say:
PHP Code:
L 09/03/2010 17:30:32: [FUNPlayer out of range (1724)
L 09/03/2010 17:30:32: [AMXXDisplaying debug trace (plugin "portal.amxx")
L 09/03/2010 17:30:32: [AMXXRun time error 10native error (native "set_user_origin")
L 09/03/2010 17:30:32: [AMXX]    [0portal.sma::Teleport (line 54
EDIT 2: Solved^^ Iīve made the teleport origin a global variable and works ^^


============================================= ===========================

Quote:
It's better to delete the portal when another of the same type is created, and yeah, in the same function.
Shoul i use a bool to check it the portal is created, and if is created, delete it and create the new portal?

============================================= ==============================

Quote:
And how are "+" commands easier than non-"+" commands ? I just use "test" command that I have bound by default to V in my game so when I test something I just press V :}
yes, i already binded "say /portal_entrance"

============================================= =============================

Quote:
So basically, you don't have anything sorted out, you need to save origins, make functions simplier so you don't just copy paste code all over the place... etc.
Yeah, i know it but i canīt this before i undestand all the code & functions
Thank you again for your help

============================================= ==============================

Sorry for teh annoying cuantity of word but i want to put my problem more detailed ;)
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.

Last edited by S34Qu4K3; 09-04-2010 at 09:29.
S34Qu4K3 is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 09-04-2010 , 12:13   Re: Put A Sprite In The Userīs Origin
Reply With Quote #22

What is the best way to remove an entity?

Iīm using:
PHP Code:
remove_entity_name("portal_entrance"
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.
S34Qu4K3 is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-04-2010 , 12:45   Re: Put A Sprite In The Userīs Origin
Reply With Quote #23

See if you get my point, just an example, I did a small test and it works:

Code:
#include <amxmodx>
#include <engine>

new g_iPortalEntity[33][2]

new Float:g_fPortalOrigin[33][2][3]

public plugin_precache()
   precache_model("sprites/e-tele1.spr")

public plugin_init()
{
   register_touch("portal", "player", "portal_touch")

   register_clcmd("portal", "cmd_portal") // use "portal 1" or "portal 2" cmds
}

public portal_touch(ent, id)
{
   static Float:fGameTime
   static Float:fLastUsage[33]

   fGameTime = get_gametime()

   if(fLastUsage[id] > fGameTime) // so it doesn't spam
      return

   fLastUsage[id] = fGameTime + 0.5 // the delay

   static iOwner

   iOwner = entity_get_edict(ent, EV_ENT_owner)

   if(iOwner != id) // only teleport in your own portals
      return

   static iOtherPortal

   iOtherPortal = (entity_get_int(ent, EV_INT_iuser1) == 1 ? 0 : 1)

   if(!g_iPortalEntity[id][iOtherPortal])
   {
      client_print(id, print_center, "The other portal doesn't exist")
      return
   }

   entity_set_origin(id, g_fPortalOrigin[id][iOtherPortal])

   client_print(id, print_center, "Teleported to portal %d", iOtherPortal + 1)
}

public cmd_portal(id)
{
   if(!is_user_alive(id))
      return PLUGIN_HANDLED

   new szPortal[2]

   read_argv(1, szPortal, charsmax(szPortal))

   new iPortal = str_to_num(szPortal) - 1

   if(!(0 <= iPortal <= 1))
      return PLUGIN_HANDLED

   new iOrigin[3]
   new iData[5]

   get_user_origin(id, iOrigin)

   iData[0] = iOrigin[0]
   iData[1] = iOrigin[1]
   iData[2] = iOrigin[2]
   iData[3] = id
   iData[4] = iPortal

   set_task(1.0, "create_portal", 0, iData, sizeof iData)

   client_print(id, print_center, "Spawning portal %d...", iPortal + 1)

   return PLUGIN_HANDLED
}

public create_portal(iData[])
{
   new ent = create_entity("env_sprite")

   if(!ent)
      return

   new id = iData[3]
   new iPortal = iData[4]
   new iOldEnt = g_iPortalEntity[id][iPortal]
   new Float:fOrigin[3]

   fOrigin[0] = 0.0 + iData[0]
   fOrigin[1] = 0.0 + iData[1]
   fOrigin[2] = 0.0 + iData[2]

   if(iOldEnt)
      remove_entity(iOldEnt)

   entity_set_string(ent, EV_SZ_classname, "portal")
   entity_set_model(ent, "sprites/e-tele1.spr")
   entity_set_edict(ent, EV_ENT_owner, id)
   entity_set_int(ent, EV_INT_spawnflags, SF_SPRITE_STARTON)
   entity_set_int(ent, EV_INT_iuser1, iPortal)
   entity_set_float(ent, EV_FL_framerate, 30.0)

   DispatchSpawn(ent)

   entity_set_origin(ent, fOrigin)
   entity_set_size(ent, Float:{-10.0, -10.0, -10.0}, Float:{10.0, 10.0, 10.0})
   entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
   entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY)
   entity_set_int(ent, EV_INT_rendermode, kRenderTransAdd)
   entity_set_float(ent, EV_FL_renderamt, 255.0)
   entity_set_float(ent, EV_FL_scale, 1.0)

   g_iPortalEntity[id][iPortal] = ent
   g_fPortalOrigin[id][iPortal] = fOrigin
}
I don't really have the time right now to explain with words too.
__________________

Last edited by Hunter-Digital; 09-04-2010 at 13:00.
Hunter-Digital is offline
S34Qu4K3
Veteran Member
Join Date: Jan 2010
Location: Galicia
Old 09-04-2010 , 13:14   Re: Put A Sprite In The Userīs Origin
Reply With Quote #24

I donīt understand some parts but i know enough to say: "Your code is better coded and more efficient that mine ^^"

My code, done with your advices and works well, is not advanced as yours but ... is a start ^^:
PHP Code:

#include <amxmodx>
#include <engine>
#include <fun>

new bool:Exit
new 
bool:Entrance
new FloatfTeleportOrigin[3]
new 
iTeleportOrigin[3]

public 
plugin_precache()
{
   
precache_model("sprites/e-tele1.spr")
}

public 
plugin_init()
{
   
register_touch("portal_entrance""player""portal_touch")

   
register_clcmd("portal_entrance""cmd_portal")
   
register_clcmd("portal_exit""cmd_portal2")
}
public 
cmd_portal(id)
{
   new 
enOrigin[3]

   
get_user_origin(idenOrigin)
   
enOrigin[2] = enOrigin[2] + 20

   client_print
(0print_chat"%d started creating portal..."id)

   
set_task(1.0"create_portal"idenOrigin3)
}
public 
cmd_portal2(id)
{
   new 
exOrigin[3]

   
get_user_origin(idexOrigin)

   
client_print(0print_chat"%d started creating portal..."id)

   
set_task(1.0"create_portal2"idexOrigin3)
}
public 
portal_touch(entid)
{   
    
    new 
Owner entity_get_edict(ent,EV_ENT_owner)
    
    if(
Owner == id)
    {
    if(!Exit)
    {
        
client_print(idprint_center"Create A Exit Portal First")
    }
    else
    {
    
        
set_user_origin(idiTeleportOrigin)
        
client_print(id,print_center,"You have been teleported")
        
client_print(idprint_chat"Teleported..")
    }
     }
     else
     {
        
client_print(idprint_center"Use your own portals")
         return
     }
    
}

public 
create_portal(enOrigin[3], id)
{
   new 
Float:fOrigin[3]
   new 
ent create_entity("env_sprite")

   
remove_entity_name("portal_entrance")
   
   
IVecFVec(enOriginfOrigin)

   
   
entity_set_string(entEV_SZ_classname"portal_entrance")
   
entity_set_model(ent"sprites/e-tele1.spr")
   
entity_set_int(entEV_INT_spawnflagsSF_SPRITE_STARTON)
   
entity_set_float(entEV_FL_framerate30.0)

   
DispatchSpawn(ent)

   
entity_set_origin(entfOrigin)
   
entity_set_size(entFloat:{-25.0, -25.0, -25.0}, Float:{25.025.025.0})
   
entity_set_int(entEV_INT_solidSOLID_TRIGGER)
   
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY)
   
entity_set_int(entEV_INT_rendermodekRenderTransAdd)
   
entity_set_float(entEV_FL_renderamt255.0)
   
entity_set_float(entEV_FL_scale1.0)
   
entity_set_edict(ent,EV_ENT_ownerid)
   
Entrance true
      
   client_print
(0print_chat"%d created portal (%d)"ident)
}
public 
create_portal2(exOrigin[3], id)
{
   new 
Float:fOrigin[3]
   
   
remove_entity_name"portal_exit" )
   
   new 
ent create_entity("env_sprite")

   
IVecFVec(exOriginfOrigin)
   
   
   
entity_set_string(entEV_SZ_classname"portal_exit")
   
entity_set_model(ent"sprites/e-tele1.spr")
   
entity_set_int(entEV_INT_spawnflagsSF_SPRITE_STARTON)
   
entity_set_float(entEV_FL_framerate30.0)

   
DispatchSpawn(ent)

   
entity_set_origin(entfOrigin)
   
entity_set_size(entFloat:{-25.0, -25.0, -25.0}, Float:{25.025.025.0})
   
entity_set_int(entEV_INT_solidSOLID_TRIGGER)
   
entity_set_int(entEV_INT_movetypeMOVETYPE_FLY)
   
entity_set_int(entEV_INT_rendermodekRenderTransAdd)
   
entity_set_float(entEV_FL_renderamt255.0)
   
entity_set_float(entEV_FL_scale1.0)
   
entity_set_edict(ent,EV_ENT_ownerid)

   
client_print(0print_chat"%d created portal (%d)"ident)
   Exit = 
true
   
   entity_get_vector
(entEV_VEC_originfTeleportOrigin)
   
   
FVecIVec(fTeleportOriginiTeleportOrigin)
   

Iīve learned to do a Owner with the tutorial: ENtyties by Hawk and iīve putted it in the code to check if the player how want to teleport is the same that the portal creator

now i must check if the player is alive, hand a important think, iīve tested my code with my friend Varchar and, if iīve created a portal and he creates a portal, my portal is deleted, should i add another owner to the code to check this?
__________________

- ASM2SMA: Experimental AMXX Assembly encoder

- Defuse Bar Fix

Quote:
Originally Posted by Arkshine
I DON'T WANT TO SEE NOOOOOOOOOOOOOOO AHHHHH. MY EYES ARE ALREADY HURT.

Last edited by S34Qu4K3; 09-04-2010 at 13:17.
S34Qu4K3 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 04:13.


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