version 1.13 | | version 1.14 |
---|
| | |
printf("Illegal call of runPluginCommand, call find_plugin_command first.\n"); | | printf("Illegal call of runPluginCommand, call find_plugin_command first.\n"); |
return 1; | | return 1; |
} | | } |
strcpy(buf, cf_get_maps_directory(CustomCommand[current_command].name)); | | snprintf(buf, sizeof(buf), "%s.py", cf_get_maps_directory(CustomCommand[current_command].name)); |
strcat(buf, ".py"); | | |
| | |
context = malloc(sizeof(CFPContext)); | | context = malloc(sizeof(CFPContext)); |
context->message[0]=0; | | context->message[0]=0; |
| | |
context->who = Crossfire_Object_wrap(op); | | context->who = Crossfire_Object_wrap(op); |
context->fix = 0; | | context->fix = 0; |
strcpy(context->script,buf); | | snprintf(context->script, sizeof(context->script), "%s", buf); |
strcpy(context->options,params); | | snprintf(context->options, sizeof(context->options), "%s", params); |
context->returnvalue = 1; /* Default is "command successful" */ | | context->returnvalue = 1; /* Default is "command successful" */ |
| | |
Py_XINCREF(context->who); | | Py_XINCREF(context->who); |
| | |
case EVENT_BORN: | | case EVENT_BORN: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_born.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_born.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_PLAYER_DEATH: | | case EVENT_PLAYER_DEATH: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->who = Crossfire_Object_wrap(op); | | context->who = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_player_death.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_player_death.py")); |
cfob = (Crossfire_Object*)context->who; | | cfob = (Crossfire_Object*)context->who; |
break; | | break; |
case EVENT_GKILL: | | case EVENT_GKILL: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->who = Crossfire_Object_wrap(op); | | context->who = Crossfire_Object_wrap(op); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_gkill.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_gkill.py")); |
cfob = (Crossfire_Object*)context->who; | | cfob = (Crossfire_Object*)context->who; |
break; | | break; |
case EVENT_LOGIN: | | case EVENT_LOGIN: |
| | |
context->activator = Crossfire_Object_wrap(pl->ob); | | context->activator = Crossfire_Object_wrap(pl->ob); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_login.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_login.py")); |
cfpl = (Crossfire_Player*)context->activator; | | cfpl = (Crossfire_Player*)context->activator; |
break; | | break; |
case EVENT_LOGOUT: | | case EVENT_LOGOUT: |
| | |
context->activator = Crossfire_Object_wrap(pl->ob); | | context->activator = Crossfire_Object_wrap(pl->ob); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_logout.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_logout.py")); |
cfpl = (Crossfire_Player*)context->activator; | | cfpl = (Crossfire_Player*)context->activator; |
break; | | break; |
case EVENT_REMOVE: | | case EVENT_REMOVE: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_remove.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_remove.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_SHOUT: | | case EVENT_SHOUT: |
| | |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_shout.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_shout.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_MUZZLE: | | case EVENT_MUZZLE: |
| | |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_muzzle.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_muzzle.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_KICK: | | case EVENT_KICK: |
| | |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_kick.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_kick.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_MAPENTER: | | case EVENT_MAPENTER: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_mapenter.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_mapenter.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_MAPLEAVE: | | case EVENT_MAPLEAVE: |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
strcpy(context->script,cf_get_maps_directory("python/events/python_mapleave.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_mapleave.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
break; | | break; |
case EVENT_CLOCK: | | case EVENT_CLOCK: |
strcpy(context->script,cf_get_maps_directory("python/events/python_clock.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_clock.py")); |
break; | | break; |
case EVENT_MAPRESET: | | case EVENT_MAPRESET: |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=NULL) | | if (buf !=NULL) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_mapreset.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_mapreset.py")); |
break; | | break; |
case EVENT_TELL: | | case EVENT_TELL: |
strcpy(context->script,cf_get_maps_directory("python/events/python_tell.py")); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory("python/events/python_tell.py")); |
break; | | break; |
} | | } |
va_end(args); | | va_end(args); |
| | |
context->third = Crossfire_Object_wrap(va_arg(args, object*)); | | context->third = Crossfire_Object_wrap(va_arg(args, object*)); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=0) | | if (buf !=0) |
strcpy(context->message,buf); | | snprintf(context->message, sizeof(context->message), "%s", buf); |
context->fix = va_arg(args, int); | | context->fix = va_arg(args, int); |
strcpy(context->script,cf_get_maps_directory(va_arg(args, char*))); | | snprintf(context->script, sizeof(context->script), "%s", cf_get_maps_directory(va_arg(args, char*))); |
strcpy(context->options,va_arg(args, char*)); | | snprintf(context->options, sizeof(context->options), "%s", va_arg(args, char*)); |
context->returnvalue = 0; | | context->returnvalue = 0; |
| | |
va_end(args); | | va_end(args); |