version 1.2 | | version 1.3 |
---|
| | |
CustomCommand[i].name = cf_strdup_local(cmdname); | | CustomCommand[i].name = cf_strdup_local(cmdname); |
CustomCommand[i].script = cf_strdup_local(scriptname); | | CustomCommand[i].script = cf_strdup_local(scriptname); |
CustomCommand[i].speed = cmdspeed; | | CustomCommand[i].speed = cmdspeed; |
i = NR_CUSTOM_CMD; | | break; |
} | | } |
}; | | }; |
| | |
| | |
| | |
va_start(args, type); | | va_start(args, type); |
propname = va_arg(args, char *); | | propname = va_arg(args, char *); |
printf("Property name: %s\n", propname); | | |
| | |
if(!strcmp(propname,"command?")) | | if(!strcmp(propname,"command?")) |
{ | | { |
| | |
{ | | { |
if (!strcmp(CustomCommand[i].name,cmdname)) | | if (!strcmp(CustomCommand[i].name,cmdname)) |
{ | | { |
printf( "PYTHON - Running command %s\n",CustomCommand[i].name); | | |
rtn_cmd.name = CustomCommand[i].name; | | rtn_cmd.name = CustomCommand[i].name; |
rtn_cmd.time = (float)CustomCommand[i].speed; | | rtn_cmd.time = (float)CustomCommand[i].speed; |
rtn_cmd.func = runPluginCommand; | | rtn_cmd.func = runPluginCommand; |
| | |
| | |
Py_XINCREF(context->who); | | Py_XINCREF(context->who); |
| | |
printf("Custom Command Script called:%s (%p)\n", context->script, context); | | |
scriptfile = fopen(context->script,"r"); | | scriptfile = fopen(context->script,"r"); |
if (scriptfile == NULL) | | if (scriptfile == NULL) |
{ | | { |
| | |
| | |
va_start(args, type); | | va_start(args, type); |
context->event_code = va_arg(args, int); | | context->event_code = va_arg(args, int); |
printf("****** Global event listener called ***********\n"); | | |
printf("- Event code: %d\n", context->event_code); | | |
| | |
context->message[0]=0; | | context->message[0]=0; |
| | |
| | |
pl = va_arg(args, player*); | | pl = va_arg(args, player*); |
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 !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_login.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_login.py")); |
cfpl = (Crossfire_Player*)context->activator; | | cfpl = (Crossfire_Player*)context->activator; |
| | |
pl = va_arg(args, player*); | | pl = va_arg(args, player*); |
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 !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_logout.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_logout.py")); |
cfpl = (Crossfire_Player*)context->activator; | | cfpl = (Crossfire_Player*)context->activator; |
| | |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_shout.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_shout.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
| | |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_muzzle.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_muzzle.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
| | |
op = va_arg(args, object*); | | op = va_arg(args, object*); |
context->activator = Crossfire_Object_wrap(op); | | context->activator = Crossfire_Object_wrap(op); |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_kick.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_kick.py")); |
cfob = (Crossfire_Object*)context->activator; | | cfob = (Crossfire_Object*)context->activator; |
| | |
break; | | break; |
case EVENT_MAPRESET: | | case EVENT_MAPRESET: |
buf = va_arg(args, char*); | | buf = va_arg(args, char*); |
if (buf !=0) | | if (buf !=NULL) |
strcpy(context->message,buf); | | strcpy(context->message,buf); |
strcpy(context->script,cf_get_maps_directory("python/events/python_mapreset.py")); | | strcpy(context->script,cf_get_maps_directory("python/events/python_mapreset.py")); |
break; | | break; |
| | |
Py_XDECREF(context->activator); | | Py_XDECREF(context->activator); |
Py_XDECREF(context->third);*/ | | Py_XDECREF(context->third);*/ |
free(context); | | free(context); |
printf("*********** Execution complete ****************\n"); | | |
| | |
return &rv; | | return &rv; |
} | | } |
| | |
Py_XINCREF(context->third); | | Py_XINCREF(context->third); |
| | |
va_end(args); | | va_end(args); |
printf("Event listener called: %i\n", context->event_code); | | |
printf("1.eventListener: Context script:%s (%p)\n", context->script, context); | | |
printf("Message: %s\n", context->message); | | |
scriptfile = fopen(context->script,"r"); | | scriptfile = fopen(context->script,"r"); |
if (scriptfile == NULL) | | if (scriptfile == NULL) |
{ | | { |
| | |
Py_XDECREF(context->activator); | | Py_XDECREF(context->activator); |
Py_XDECREF(context->third);*/ | | Py_XDECREF(context->third);*/ |
free(context); | | free(context); |
printf("Execution complete"); | | |
return &rv; | | return &rv; |
} | | } |
| | |