AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Use custom Sprite there when precached (https://forums.alliedmods.net/showthread.php?t=25018)

Stephen 03-06-2006 08:13

Use custom Sprite there when precached
 
Code:
#include <amxmodx> #include <engine> #include <fakemeta> #include <amxmisc> #include <string> #include <fun> #define TE_FIREFIELD 123 public plugin_init() {     register_plugin("stuff","Beta","Stephen")     register_clcmd(".fx.fxFireField","fieldfire",ADMIN_ALL,"[radius], [sprite], [count], [flags], [duration]")     return PLUGIN_CONTINUE; } new smoke public fieldfire(id, level, cid, radius, count, flags, duration) {     if(!cmd_access(id,level,cid,5))             return PLUGIN_HANDLED     new user[33], space[1], many[1], dothat[1], life[1]     read_argv(0, user, 32)     read_argv(1, space, 33)//RADIUS     new radius = str_to_num(space)     read_argv(2, many, 33)//count     new count = str_to_num(many)     read_argv(3, dothat, 33)//flags     new flags = str_to_num(dothat)     read_argv(4, life, 33)//flags     new duration = str_to_num(life)     new spriteorigin[3]         get_user_origin(id, spriteorigin);         message_begin(MSG_BROADCAST,SVC_TEMPENTITY, spriteorigin);         write_byte( TE_FIREFIELD );         write_coord( spriteorigin[0] ); //coord coord coord (position)     write_coord( spriteorigin[1] );     write_coord( spriteorigin[2] );     write_short( radius ); //Radius     write_short( smoke );         write_byte( count ); // count     write_byte( flags ); //flags     write_byte( duration ); // duration in sec.         message_end();         return PLUGIN_HANDLED } //Precaching Sprites //================================== public plugin_precache() {     smoke = precache_model("sprites/smoke.spr");         return PLUGIN_HANDLED }

How can i make it that when i type in the console
.fx.fxFireField 100 "sprites"<--- 5 2 100 : that i can choose an other sprite instead of recompiling it with an other sprite ?
cause all the other stuff works but im binded to that 1 one sprite. >_>
So HOW is that possible ?

Charr 03-06-2006 08:32

You could try precaching several sprites, and use an if() system when showing the sprite.

Stephen 03-06-2006 08:39

Can you show me an snippet of how it would be putted in the plugin where i have now ?

Stephen 03-06-2006 09:43

What i would like to have is this.
Code:
.fx.fxFireField radius "spritepath/sprite" count flags duration
Like that i want it to be enterable in the console

Charr 03-06-2006 15:18

When a sprite is precached, the returned value is pointer (location in memory) so using a string in the message probably won't work. Instead you can use this:

Code:
#include <amxmodx> #include <engine> #include <fakemeta> #include <amxmisc> #include <string> #include <fun> #define TE_FIREFIELD 123 new gSpr[3],smoke; public plugin_init() {     register_plugin("stuff","Beta","Stephen")     register_clcmd(".fx.fxFireField","fieldfire",ADMIN_ALL,"[radius], [sprite], [count], [flags], [duration]")     return PLUGIN_CONTINUE; } public fieldfire(id, level, cid) {     if(!cmd_access(id,level,cid,5))             return PLUGIN_HANDLED     new sprite[33],space[32], many[32], dothat[32], life[32]     read_argv(1, space, 33)//RADIUS     new radius = str_to_num(space)     read_argv(2,sprite,31);     read_argv(3, many, 33)//count     new count = str_to_num(many)     read_argv(4, dothat, 33)//flags     new flags = str_to_num(dothat)     read_argv(5, life, 33)//flags     new duration = str_to_num(life)     new spriteorigin[3]     get_user_origin(id, spriteorigin);     message_begin(MSG_BROADCAST,SVC_TEMPENTITY, spriteorigin);     write_byte( TE_FIREFIELD );     write_coord( spriteorigin[0] ); //coord coord coord (position)     write_coord( spriteorigin[1] );     write_coord( spriteorigin[2] );     write_short( radius ); //Radius     if(equali(sprite,"smoke"))     {         write_short( smoke );     }     else if(equali(sprite,"1"))     {         write_short(gSpr[0]);     }     else if(equali(sprite,"2"))     {         write_short(gSpr[1]);     }     else if(equali(sprite,"3"))     {         write_short(gSpr[2]);     }     else     {         write_short(smoke);     }     write_byte( count ); // count     write_byte( flags ); //flags     write_byte( duration ); // duration in sec.     message_end();     return PLUGIN_HANDLED } //Precaching Sprites //================================== public plugin_precache() {     smoke = precache_model("sprites/smoke.spr");     spr[0] = precache_sprite("sprites/1.spr");     spr[1] = precache_sprite("sprites/2.spr");     spr[2] = precache_sprite("sprites/3.spr");         return PLUGIN_HANDLED }

Stephen 03-06-2006 16:08

:cry: It didnt compile.

Got 4 Errors.

Charr 03-07-2006 14:27

Stupid mistakes, my bad:
Code:
#include <amxmodx> #include <engine> #include <fakemeta> #include <amxmisc> #include <string> #include <fun> #define TE_FIREFIELD 123 new gSpr[3],smoke; public plugin_init() {     register_plugin("stuff","Beta","Stephen")     register_clcmd(".fx.fxFireField","fieldfire",ADMIN_ALL,"[radius], [sprite], [count], [flags], [duration]")     return PLUGIN_CONTINUE; } public fieldfire(id, level, cid) {     if(!cmd_access(id,level,cid,5))             return PLUGIN_HANDLED     new sprite[33],space[32], many[32], dothat[32], life[32]     read_argv(1, space, 33)//RADIUS     new radius = str_to_num(space)     read_argv(2,sprite,31);     read_argv(3, many, 33)//count     new count = str_to_num(many)     read_argv(4, dothat, 33)//flags     new flags = str_to_num(dothat)     read_argv(5, life, 33)//flags     new duration = str_to_num(life)     new spriteorigin[3]     get_user_origin(id, spriteorigin);     message_begin(MSG_BROADCAST,SVC_TEMPENTITY, spriteorigin);     write_byte( TE_FIREFIELD );     write_coord( spriteorigin[0] ); //coord coord coord (position)     write_coord( spriteorigin[1] );     write_coord( spriteorigin[2] );     write_short( radius ); //Radius     if(equali(sprite,"smoke"))     {         write_short( smoke );     }     else if(equali(sprite,"1"))     {         write_short(gSpr[0]);     }     else if(equali(sprite,"2"))     {         write_short(gSpr[1]);     }     else if(equali(sprite,"3"))     {         write_short(gSpr[2]);     }     else     {         write_short(smoke);     }     write_byte( count ); // count     write_byte( flags ); //flags     write_byte( duration ); // duration in sec.     message_end();     return PLUGIN_HANDLED } //Precaching Sprites //================================== public plugin_precache() {     smoke = precache_model("sprites/smoke.spr");     gSpr[0] = precache_model("sprites/1.spr");     gSpr[1] = precache_model("sprites/2.spr");     gSpr[2] = precache_model("sprites/3.spr");         return PLUGIN_HANDLED }


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

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