AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spawn sprite problem - code inside, needs fix (https://forums.alliedmods.net/showthread.php?t=11168)

LynX 03-11-2005 11:15

Spawn sprite problem - code inside, needs fix
 
Ok, I wrote this small plugin to try to spawn sprite. Could you guys be so kind and polish it up so sprite shows on players position - sprite should totally hide player, so other players don't see that player whos using sprite until sprite vanishes. the code:
Code:
public plugin_init(id) {     register_plugin("Test","unknown","LynX")     register_clcmd("test","spawn_sprite")     return PLUGIN_CONTINUE } new sprite public spawn_sprite(id) {     new origin[3]     message_begin(MSG_ALL,SVC_TEMPENTITY)     write_entity(id)     write_coord(origin[0]) // x coordinate     write_coord(origin[1]) // y coordinate     write_coord(origin[2]) // z coordinate     write_short( sprite )  // sprite name     write_short( 6.0 )     // sprite life     message_end()     return PLUGIN_HANDLED } public plugin_precache() {     sprite = precache_model("sprites/testsprite.spr")     return PLUGIN_CONTINUE }

Knare 03-11-2005 12:15

umm gotta go but got
Code:
#include <amxmodx> //don't to include the include files or the compiler doesnt recognize any of the code #include <engine> // for origins, co-ods, etc. public plugin_init() {     register_plugin("Test","unknown","LynX")     register_clcmd("test","spawn_sprite")     return PLUGIN_CONTINUE } new sprite public spawn_sprite(id) {    new name[32],origin[3]    get_user_origin(id,name,31)    write_entity(id)    write_coord(origin[0]) // x coordinate    write_coord(origin[1]) // y coordinate    write_coord(origin[2]) // z coordinate    write_short(sprite)  // sprite name    message_end()    return PLUGIN_HANDLED } public plugin_precache() {    sprite = precache_model("sprites/testsprite.spr")    return PLUGIN_CONTINUE }

my teacher is gonna kill me (1 error, line 20)

LynX 03-11-2005 12:19

Ok, thanks!

[edit] - I was in hurry, so I didn't posted include files in, but it compiled, and didn't showed sprite - I'm gonna test your thing now...

[edit2] - doesn't compiles, array size problem on get_user_origin line...

knekter 03-11-2005 12:32

ouch
 
Code:
new origin[3] get_user_origin(id, origin, 0) // id, array origin, 0 means current origin



Code:

/* Gets origin from player.
* Modes:
* 0 - current position.
* 1 - position from eyes (weapon aiming).
* 2 - end position from player position.
* 3 - end position from eyes (hit point for weapon).
* 4 - position of last bullet hit (only CS). */
native get_user_origin(index, origin[3], mode = 0);


LynX 03-11-2005 14:25

Okay, I'll try... But how to make sprite lasts only for number of seconds I defined, or how do I remove it once its spawned?

LynX 03-11-2005 14:39

Now I have this:
Code:
#include <amxmodx> #include <engine> public plugin_init(id) {     register_plugin("Test","unknown","LynX")     register_clcmd("test","spawn_sprite")     return PLUGIN_CONTINUE } new sprite public spawn_sprite(id) {     new origin[3]     get_user_origin(id, origin, 0) // id, array origin, 0 means current origin     message_begin(MSG_ALL,SVC_TEMPENTITY)     write_entity(id)     write_coord(origin[0]) // x coordinate     write_coord(origin[1]) // y coordinate     write_coord(origin[2]) // z coordinate     write_short( sprite )  // sprite name     write_short( 6.0 )     // sprite life     message_end()     return PLUGIN_HANDLED } public plugin_precache() {     sprite = precache_model("sprites/testsprite.spr")     return PLUGIN_CONTINUE }

When I compile it, its fine.
But when I try to use it ingame ( I have adecquate sprite for plugin ), it crashes with this message:
Quote:

PF_WriteEntity_I called with no active message
Please, help me :cry:

Knare 03-11-2005 14:39

My code was, well, rushed because I was coding in a very annoying computer class where we were learning how to use MS Excel

knekter 03-11-2005 15:50

I see the problem
 
You never defined what message your using, try this:

Code:
message_begin(MSG_ALL,SVC_TEMPENTITY) write_byte(124) // TE_PLAYERATTACHMENT write_entity(id) write_coord(origin[0]) // x coordinate write_coord(origin[1]) // y coordinate write_coord(origin[2]) // z coordinate write_short( sprite ) // sprite name write_short( 6.0 ) // sprite life message_end()

LynX 03-11-2005 16:00

I'm going to try it now...

LynX 03-11-2005 16:07

Now quits to main menu without any message... I'm ok, now desperate :(


All times are GMT -4. The time now is 14:13.

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