void gsc_player_isonladder(int id) { int flags = PLAYERSTATE(id) + 0xc; if(*(int*)flags & 32) stackPushInt(1); else stackPushInt(0); }
void gsc_player_ismantling(int id) { int flags = PLAYERSTATE(id) + 0xc; if(*(int*)flags & 4) //oi m8 im mantling stackPushInt(1); else stackPushInt(0); }
void gsc_player_getcooktime(int id) { int nadetime = PLAYERSTATE(id) + 60; if(*(int*)nadetime) stackPushInt(*(int*)nadetime); else stackPushInt(0); }
void gsc_player_getfps(int id) { extern int clfps[64][20]; int total = 0; for(int i = 0; i < sizeof(clfps[0]) / sizeof(int); i++) { if(clfps[id][i] == -1) { stackPushInt(-1); return; } total += clfps[id][i]; } stackPushInt(total); }
void gsc_player_getlastgamestatesize(int id) { extern int gamestate_size[64]; if (gamestate_size[id]) stackPushInt(gamestate_size[id]); else stackPushUndefined(); }
void gsc_player_resetfps(int id) { extern int clfps[64][20]; extern int clfpstemp[64]; for(int i = 0; i < sizeof(clfps[0]) / sizeof(int); i++) clfps[id][i] = -1; clfpstemp[id] = 0; stackPushInt(0); }
void gsc_player_resetNextReliableTime(int id) { #if COD_VERSION == COD2_1_0 int offset = 134412; #else int offset = 134684; #endif *(int *)(PLAYERBASE(id) + offset) = 0; stackPushInt(0); }
void gsc_player_getping(int id) { #if COD_VERSION == COD2_1_0 || COD_VERSION == COD2_1_0_1 int info_port_offset = 0x6E5A4; #elif COD_VERSION == COD2_1_3 int info_port_offset = 0x6E6B4; #else #warning gsc_player_getping() got no working addresses int info_port_offset = 0x0; #endif int info_player = PLAYERBASE(id); int ping = *(unsigned int *)(info_player + info_port_offset); stackPushInt(ping); }
void gsc_player_getLastConnectTime(int id) { #if COD_VERSION == COD2_1_0 int info_connecttime_offset = 0x20D14; #elif COD_VERSION == COD2_1_2 int info_connecttime_offset = 0x20E24; #elif COD_VERSION == COD2_1_3 int info_connecttime_offset = 0x20E24; #else #warning gsc_player_getLastConnectTime() got no working addresses int info_connecttime_offset = 0x0; #endif int lastconnect = getSVSTime() - *(unsigned int *)(PLAYERBASE(id) + info_connecttime_offset); stackPushInt(lastconnect); }
void gsc_player_setg_speed(int id) { int speed; if ( ! stackGetParams("i", &speed)) { printf("scriptengine> ERROR: gsc_player_setg_speed(): param \"speed\"[1] has to be an int!\n"); stackPushUndefined(); return; } if (speed < 0) { printf("scriptengine> ERROR: gsc_player_setg_speed(): param \"speed\"[1] must be equal or above zero!\n"); stackPushUndefined(); return; } player_g_speed[id] = speed; stackPushInt(1); }
void gsc_player_setg_gravity(int id) { int gravity; if ( ! stackGetParams("i", &gravity)) { printf("scriptengine> ERROR: gsc_player_setg_gravity(): param \"gravity\"[1] has to be an int!\n"); stackPushUndefined(); return; } if (gravity < 0) { printf("scriptengine> ERROR: gsc_player_setg_gravity(): param \"gravity\"[1] must be equal or above zero!\n"); stackPushUndefined(); return; } player_g_gravity[id] = gravity; stackPushInt(1); }
void gsc_player_setmovespeedscale(int id) { float scale; if ( ! stackGetParams("f", &scale)) { printf("scriptengine> ERROR: gsc_player_setmovespeedscale(): param \"scale\"[1] has to be an float!\n"); stackPushUndefined(); return; } if (scale <= 0) { printf("scriptengine> ERROR: gsc_player_setmovespeedscale(): param \"scale\"[1] must be above zero!\n"); stackPushUndefined(); return; } player_movespeedscale[id] = scale; stackPushInt(1); }
void gsc_player_getping(int id) { #if COD_VERSION == COD2_1_0 int info_ping_offset = 0x6E5A4; #elif COD_VERSION == COD2_1_2 int info_ping_offset = 0x6E6B4; #elif COD_VERSION == COD2_1_3 int info_ping_offset = 0x6E6B4; #elif COD_VERSION == COD4_1_7 || COD_VERSION == COD4_1_7_L int info_ping_offset = 0x804EC; #else #warning gsc_player_getport() got no working addresses int info_ping_offset = 0x0; #endif int ping = *(unsigned int *)(PLAYERBASE(id) + info_ping_offset); stackPushInt(ping); }
void gsc_player_renameclient(int id) { char * key; if ( ! stackGetParams("s", &key)) { printf("scriptengine> ERROR: gsc_player_renameclient(): param \"key\"[1] has to be an string!\n"); stackPushUndefined(); return; } int info_player = PLAYERBASE(id); Info_SetValueForKey((char *)(info_player + 12), "name", key); char * name = (char *)(info_player + 134216); memcpy(&name[0], key, 32); name[31] = '\0'; printf("name = %s\n", name); stackPushInt(1); }
void gsc_player_getLastConnectTime(int id) { #if COD_VERSION == COD2_1_0 int info_start = *(int *)0x0C09904; int info_connecttime_offset = 0x20D14; #elif COD_VERSION == COD2_1_0_1 int info_start = *(int *)0x0C0B104; int info_connecttime_offset = 0x20D14; #elif COD_VERSION == COD2_1_3 int info_start = *(int *)0x0D35704; int info_connecttime_offset = 0x20E24; #else #warning gsc_player_getLastConnectTime() got no working addresses int info_start = *(int *)0x0; int info_connecttime_offset = 0x0; #endif int info_player = PLAYERBASE(id); int lastconnect = info_start - *(unsigned int *)(info_player + info_connecttime_offset); stackPushInt(lastconnect); }
void gsc_player_getLastMSG(int id) { #if COD_VERSION == COD2_1_0 int info_start = *(int *)0x0C09904; int info_lastmsg_offset = 0x20D10; #elif COD_VERSION == COD2_1_0_1 int info_start = *(int *)0x0C0B104; int info_lastmsg_offset = 0x20D10; #elif COD_VERSION == COD2_1_3 int info_start = *(int *)0x0D35704; int info_lastmsg_offset = 0x20E20; #else #warning gsc_player_getlastmsg() got no working addresses int info_start = *(int *)0x0; int info_lastmsg_offset = 0x0; #endif int info_player = PLAYERBASE(id); int lastmsg = info_start - *(unsigned int *)(info_player + info_lastmsg_offset); stackPushInt(lastmsg); }
void gsc_player_getclientstate(int id) { int info_player = PLAYERBASE(id); stackPushInt(*(int*)info_player); }
void gsc_exec_async_checkdone() { exec_async_task *current = first_exec_async_task; while (current != NULL) { exec_async_task *task = current; current = current->next; if (task->done) { //push to cod if (Scr_IsSystemActive() && task->save && task->callback && !task->error && (scrVarPub.levelId == task->levelId)) { if (task->hasargument) { switch(task->valueType) { case INT_VALUE: stackPushInt(task->intValue); break; case FLOAT_VALUE: stackPushFloat(task->floatValue); break; case STRING_VALUE: stackPushString(task->stringValue); break; case VECTOR_VALUE: stackPushVector(task->vectorValue); break; case OBJECT_VALUE: stackPushObject(task->objectValue); break; default: stackPushUndefined(); break; } } stackPushArray(); exec_outputline *output = task->output; while (output != NULL) { exec_outputline *next = output->next; stackPushString(output->content); stackPushArrayLast(); delete output; output = next; } short ret = Scr_ExecThread(task->callback, task->save + task->hasargument); Scr_FreeThread(ret); } //free task if (task->next != NULL) task->next->prev = task->prev; if (task->prev != NULL) task->prev->next = task->next; else first_exec_async_task = task->next; delete task; } } }
void gsc_player_getLastMSG(int id) { int lastmsg = getSVSTime() - *(unsigned int *)getLastPacketTime(id); stackPushInt(lastmsg); }
void gsc_player_ClientCommand(int id) { stackPushInt(ClientCommand(id)); }
void gsc_player_clientuserinfochanged(int id) { stackPushInt(changeClientUserinfo(id)); }
void gsc_player_addresstype(int id) { stackPushInt(getAddressType(id)); }
void gsc_exec_async_create_nosave() { char *command; int callback; if (!stackGetParamString(0, &command)) { stackError("gsc_exec_async_create_nosave() argument is undefined or has wrong type"); stackPushUndefined(); return; } Com_DPrintf("gsc_exec_async_create_nosave() executing: %s\n", command); exec_async_task *current = first_exec_async_task; while (current != NULL && current->next != NULL) current = current->next; exec_async_task *newtask = new exec_async_task; strncpy(newtask->command, command, COD2_MAX_STRINGLENGTH - 1); newtask->command[COD2_MAX_STRINGLENGTH - 1] = '\0'; newtask->output = NULL; newtask->prev = current; newtask->next = NULL; if (!stackGetParamFunction(1, &callback)) newtask->callback = 0; else newtask->callback = callback; newtask->done = false; newtask->save = false; newtask->error = false; newtask->levelId = scrVarPub.levelId; newtask->hasargument = true; int valueInt; float valueFloat; char *valueString; vec3_t valueVector; unsigned int valueObject; if (stackGetParamInt(2, &valueInt)) { newtask->valueType = INT_VALUE; newtask->intValue = valueInt; } else if (stackGetParamFloat(2, &valueFloat)) { newtask->valueType = FLOAT_VALUE; newtask->floatValue = valueFloat; } else if (stackGetParamString(2, &valueString)) { newtask->valueType = STRING_VALUE; strcpy(newtask->stringValue, valueString); } else if (stackGetParamVector(2, valueVector)) { newtask->valueType = VECTOR_VALUE; newtask->vectorValue[0] = valueVector[0]; newtask->vectorValue[1] = valueVector[1]; newtask->vectorValue[2] = valueVector[2]; } else if (stackGetParamObject(2, &valueObject)) { newtask->valueType = OBJECT_VALUE; newtask->objectValue = valueObject; } else newtask->hasargument = false; if (current != NULL) current->next = newtask; else first_exec_async_task = newtask; pthread_t exec_doer; if (pthread_create(&exec_doer, NULL, exec_async, newtask) != 0) { stackError("gsc_exec_async_create_nosave() error creating exec async handler thread!"); stackPushUndefined(); return; } if (pthread_detach(exec_doer) != 0) { stackError("gsc_exec_async_create_nosave() error detaching exec async handler thread!"); stackPushUndefined(); return; } stackPushInt(1); }