Raised This Month: $ Target: $400
 0% 

[Resolved] pfn_touch will not work for me? Help plz!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-29-2006 , 21:04   [Resolved] pfn_touch will not work for me? Help plz!
Reply With Quote #1

I am trying to make a function run when a player touches a spawned entity. Each time I touch the entity the function doesn't run though. Can someone please help me with my code and tell me why?

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Speedeh" #define VERSION "1.0" #define AUTHOR "hlstriker" const MAX_NAME_LENGTH = 31; new startModel[] = "models/v_tfc_rpg.mdl"; new endModel[] = "models/esad_8ball.mdl"; new bool:startCreated; new bool:endCreated; new Float:hour; new Float:minute; new Float:second; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_concmd("amx_addstart", "setStart", ADMIN_BAN, " - adds a start point for the timer");     register_concmd("amx_addend", "setEnd", ADMIN_BAN, " - adds an end point for the timer"); } public plugin_precache() {     precache_model(startModel);     precache_model(endModel); } public setStart(id) {     if(startCreated) {         return PLUGIN_HANDLED;     }         // Get players origin for where to set starter     new Float:origin[3];     entity_get_vector(id, EV_VEC_origin, origin);         // Create the entity     new startEnt = create_entity("info_target");         // Set the class name for a touch     entity_set_string(startEnt, EV_SZ_classname, "startTimer");         // Set the model     entity_set_model(startEnt, startModel);         // Set new entities origin     entity_set_origin(startEnt, origin);         // Set Movetype Solidtype + Owner     entity_set_int(startEnt, EV_INT_solid, SOLID_NOT);     entity_set_int(startEnt, EV_INT_movetype, MOVETYPE_FLY);     entity_set_edict(startEnt, EV_ENT_owner, 33);         // Set Model's play sequence (Framerate 1.0 means normal speed + sequence 0 is the idle sequence)     entity_set_float(startEnt, EV_FL_framerate, 1.0);     entity_set_int(startEnt, EV_INT_sequence, 0);         //Set size of invisible box that is interactive w/ players (depending on solid type)     new Float:minStart[3];     minStart[0]=-10.0;     minStart[1]=-10.0;     minStart[2]=-10.0;     new Float:maxStart[3];     maxStart[0]=10.0;     maxStart[1]=10.0;     maxStart[2]=10.0;     entity_set_size(startEnt,minStart,maxStart);         startCreated = true;         return PLUGIN_CONTINUE; } public setEnd(id) {     if(endCreated) {         return PLUGIN_HANDLED;     }         // Get players origin for where to set starter     new Float:origin[3];     entity_get_vector(id, EV_VEC_origin, origin);         // Create the entity     new endEnt = create_entity("info_target");         // Set the class name for a touch     entity_set_string(endEnt, EV_SZ_classname, "endTimer");         // Set the model     entity_set_model(endEnt, endModel);         // Set new entities origin     entity_set_origin(endEnt, origin);         // Set Movetype Solidtype + Owner     entity_set_int(endEnt, EV_INT_solid, SOLID_NOT);     entity_set_int(endEnt, EV_INT_movetype, MOVETYPE_FLY);     entity_set_edict(endEnt, EV_ENT_owner, 33);         // Set Model's play sequence (Framerate 1.0 means normal speed + sequence 0 is the idle sequence)     entity_set_float(endEnt, EV_FL_framerate, 1.0);     entity_set_int(endEnt, EV_INT_sequence, 0);         //Set size of invisible box that is interactive w/ players (depending on solid type)     new Float:minEnd[3];     minEnd[0]=-10.0;     minEnd[1]=-10.0;     minEnd[2]=-10.0;     new Float:maxEnd[3];     maxEnd[0]=10.0;     maxEnd[1]=10.0;     maxEnd[2]=10.0;     entity_set_size(endEnt,minEnd,maxEnd);         endCreated = true;         return PLUGIN_CONTINUE; } public pfn_touch(ptr, ptd) {     new toucher[MAX_NAME_LENGTH];     new touched[MAX_NAME_LENGTH];     entity_get_string(ptr, EV_SZ_classname, toucher, MAX_NAME_LENGTH-1);     entity_get_string(ptd, EV_SZ_classname, touched, MAX_NAME_LENGTH-1);     if(equal(toucher,"startTimer") && equal(touched,"player"))     {         hour = 0.0;         minute = 0.0;         second = 1.0;         set_task(1.0, "timerCount", ptd, "", 0, "b");     }         return PLUGIN_CONTINUE; } public timerCount(ptd) {     second += 1.0         if(second == 60.0) {         second = 0.0         minute += 1.0     }         if(minute == 60.0) {         minute = 0.0         hour += 1.0     }         new strHour[3];     new strMinute[3];     new strSecond[3];         float_to_str(hour, strHour, 2);     float_to_str(minute, strMinute, 2);     float_to_str(second, strSecond, 2);         switch(hour) {         case 0.0: strHour = "00";         case 1.0: strHour = "01";         case 2.0: strHour = "02";         case 3.0: strHour = "03";         case 4.0: strHour = "04";         case 5.0: strHour = "05";         case 6.0: strHour = "06";         case 7.0: strHour = "07";         case 8.0: strHour = "08";         case 9.0: strHour = "09";     }         switch(minute) {         case 0.0: strMinute = "00";         case 1.0: strMinute = "01";         case 2.0: strMinute = "02";         case 3.0: strMinute = "03";         case 4.0: strMinute = "04";         case 5.0: strMinute = "05";         case 6.0: strMinute = "06";         case 7.0: strMinute = "07";         case 8.0: strMinute = "08";         case 9.0: strMinute = "09";     }         switch(second) {         case 0.0: strSecond = "00";         case 1.0: strSecond = "01";         case 2.0: strSecond = "02";         case 3.0: strSecond = "03";         case 4.0: strSecond = "04";         case 5.0: strSecond = "05";         case 6.0: strSecond = "06";         case 7.0: strSecond = "07";         case 8.0: strSecond = "08";         case 9.0: strSecond = "09";     }         set_hudmessage(200, 100, 0, -1.0, -5.0, 0, 0.0, 0.9, 0.0, 0.0, 4);     show_hudmessage(ptd, "%s:%s:%s", strHour, strMinute, strSecond);         return PLUGIN_CONTINUE; }

Last edited by hlstriker; 11-30-2006 at 00:11. Reason: Resolved
hlstriker is offline
The Specialist
BANNED
Join Date: Nov 2006
Old 11-29-2006 , 22:40   Re: pfn_touch will not work for me? Help plz!
Reply With Quote #2

try using register touch instead of pfn_touch
Code:
  // plugin_init() register_touch("My_Ent","player","function_to_be_called")   public function_to_be_called() {          whatever }
The Specialist is offline
Send a message via AIM to The Specialist
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-29-2006 , 23:05   Re: pfn_touch will not work for me? Help plz!
Reply With Quote #3

Thanks, got it working
hlstriker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 00:11   Re: [Resolved] pfn_touch will not work for me? Help plz!
Reply With Quote #4

you can use this
format(strHour,2,"%02d",floatround(hour))
instead of switch stuff
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang 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 07:01.


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