AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Creating an entity between two points (https://forums.alliedmods.net/showthread.php?t=24587)

Des12 02-26-2006 17:25

Creating an entity between two points
 
Hello, I want to create a tripwire type thing. Would it be possible to create an invisable entity between two points, and register a touch between it and a player?

I looked at the tripmine plugin and found a traceline. So lets say this:

Code:
public checkLine() { new origin[3] = { 50, 50, 50}; new origin2[3] = { 75, 75, 50}; //trace_line ( IgnoreEnt, Float:Start[3], Float:End[3], Float:vReturn[3] ) new id = trace_line ( -1, float(origin), float(origin2), /*what do I put here?*/ ); if(is_user_alive(id))     client_print(0,print_chat,"[AMXX] User has crossed into the line!"); set_task(0.1,checkLine); }

Would that work in detecting a user crossing a line? And what is the vReturn?

Kraugh 02-26-2006 18:03

try making an env_beam or env_laser and registering its touches.

Hawk552 02-26-2006 18:28

Quote:

Originally Posted by Kraugh
try making an env_beam or env_laser and registering its touches.

I don't think it registers a touch if it's not solid.

To do that, you'd have to set it to solid and then try it, but that would make the player unable to move through it.

Kraugh 02-26-2006 18:53

they do register a touch, that's how they deal damage when you run through them. i believe they are SOLID_TRIGGER: they register a touch but do not block.

Des12 02-26-2006 19:14

So creating an env_beam/laser, how would I disable the damange and set the start/endpoints?

Kraugh 02-26-2006 19:54

http://collective.valve-erc.com/index.php?ent=env_beam

use DispatchKeyValue to assign these values.

Des12 03-04-2006 11:18

Alright, here is the code (it crashes the server)

The beacons work totally fine, but the env_beam crashes when they are activated.

Code:
public plugin_precache() {     precache_model ( BEACONMODEL );     tape = precache_model("sprites/rope.spr");      } public activateBeacons(id) {     switch(beaconcount[id]) {     case 2: {         tape1[id] = create_entity("env_beam");         entity_set_string(tape1[id],EV_SZ_classname,"beacon");           DispatchKeyValue (tape1[id], "LightningStart", beacon1[id]);         DispatchKeyValue (tape1[id], "LightningEnd", beacon2[id]);         DispatchKeyValue (tape1[id], "texture", tape);         DispatchKeyValue (tape1[id], "rendercolor" , "0 0 255");         //DispatchKeyValue (tape1[id], renderamt  , "0 0 255");         DispatchKeyValue (tape1[id], "life" , "0");                             DispatchSpawn ( tape1[id] );     }     case 3: {         tape2[id] = create_entity("env_beam");         entity_set_string(tape2[id],EV_SZ_classname,"beacon");           DispatchKeyValue (tape2[id], "LightningStart", beacon2[id]);         DispatchKeyValue (tape2[id], "LightningEnd", beacon3[id]);         DispatchKeyValue (tape2[id], "texture", tape);         DispatchKeyValue (tape2[id], "rendercolor" , "0 0 255");         //DispatchKeyValue (tape2[id], renderamt  , "0 0 255");         DispatchKeyValue (tape2[id], "life" , "0");                             DispatchSpawn ( tape2[id] );     }     //Two here because the last beacon and first beacon can link     case 4: {         tape3[id] = create_entity("env_beam");         entity_set_string(tape3[id],EV_SZ_classname,"beacon");           DispatchKeyValue (tape3[id], "LightningStart", beacon3[id]);         DispatchKeyValue (tape3[id], "LightningEnd", beacon4[id]);         DispatchKeyValue (tape3[id], "texture", tape);         DispatchKeyValue (tape3[id], "rendercolor" , "0 0 255");         //DispatchKeyValue (tape3[id], renderamt  , "0 0 255");         DispatchKeyValue (tape3[id], "life" , "0");                             DispatchSpawn ( tape3[id] );         tape4[id] = create_entity("env_beam");         entity_set_string(tape4[id],EV_SZ_classname,"beacon");           DispatchKeyValue (tape4[id], "LightningStart", beacon4[id]);         DispatchKeyValue (tape4[id], "LightningEnd", beacon1[id]);         DispatchKeyValue (tape4[id], "texture", tape);         DispatchKeyValue (tape4[id], "rendercolor" , "0 0 255");         //DispatchKeyValue (tape4[id], renderamt  , "0 0 255");         DispatchKeyValue (tape4[id], "life" , "0");                             DispatchSpawn ( tape4[id] );     }     }     return PLUGIN_HANDLED; }

Kraugh 03-04-2006 14:24

did you not get tag mismatches when you compiled? i thought the third parameter of DispatchKeyValue had to be a string. anyway, for the texture key, use "sprites/rope.spr" instead of "tape" (you still need to precache it, however).

VEN 03-04-2006 14:32

edit: hm, i was in rush so nvm

Kraugh 03-04-2006 14:55

actually he's using entity_set_string for that, so it should be fine. i'd wait until after DispatchSpawn to change it, though, so that the beam is created successfully. it might not cause any problems, though.


All times are GMT -4. The time now is 20:24.

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