int gsc_mysql_real_connect() { int mysql; char *host; char *user; char *pass; char *db; int port; int helper = 0; helper += stackGetParamInt(1, &mysql); helper += stackGetParamString(2, &host); helper += stackGetParamString(3, &user); helper += stackGetParamString(4, &pass); helper += stackGetParamString(5, &db); helper += stackGetParamInt(6, &port); #if DEBUG_MYSQL printf_hide("gsc_mysql_real_connect(mysql=%d, host=\"%s\", user=\"%s\", pass=\"%s\", db=\"%s\", port=%d)\n", mysql, host, user, pass, db, port); #endif if (helper != 6) { printf_hide("scriptengine> wrongs args for mysql_real_connect(...);\n"); return stackPushUndefined(); } mysql = (int) mysql_real_connect((MYSQL *)mysql, host, user, pass, db, port, NULL, 0); return stackReturnInt(mysql); }
void gsc_kick_slot() { int id; char* msg; char* reason; if ( ! stackGetParams("is", &id, &msg)) { printf("scriptengine> ERROR: gsc_kick_slot(): param \"id\"[1] has to be an int!\n"); printf("scriptengine> ERROR: gsc_kick_slot(): param \"msg\"[2] has to be an string!\n"); stackPushUndefined(); return; } if(getAddressType(id) == NA_LOOPBACK) { stackReturnInt(0); return; // host } #if COD_VERSION == COD2_1_0 int guid_offset = 0x765F4; #elif COD_VERSION == COD2_1_2 int guid_offset = 0x76704; #elif COD_VERSION == COD2_1_3 int guid_offset = 0xAE704; #else #warning gsc_kick_slot() got no working addresses for guid_offset int guid_offset = 0x0; #endif int entity = PLAYERBASE(id); char* name = Info_ValueForKey((char*)entity+12, "name"); // read before drop client resets the userinfo int guid = *(int*)(entity + guid_offset); SV_DropClient(entity, msg); int * lastPacketTime = (int*)getLastPacketTime(id); *lastPacketTime = getSVSTime(); // in case there is a funny zombie (copied from Q3) if(!stackGetParamString(2, &reason)) { Com_Printf("%s (guid %i) was kicked\n", name, guid); stackReturnInt(1); return; } Com_Printf("%s (guid %i) was kicked for %s\n", name, guid, reason); stackReturnInt(1); }
int gsc_mysql_init() { #if DEBUG_MYSQL printf_hide("gsc_mysql_init()\n"); #endif MYSQL *my; my = mysql_init(NULL); int ret = (int) my; return stackReturnInt(ret); }
int gsc_mysql_stmt_get_field_count() { int mysql_stmt; int helper = 0; helper += stackGetParamInt(1, &mysql_stmt); #if DEBUG_MYSQL printf_hide("gsc_mysql_stmt_get_field_count(mysql_stmt=%d)\n", mysql_stmt); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for gsc_mysql_stmt_get_field_count(mysql_stmt);\n"); return stackReturnInt(0); } int ret = ((MYSQL_STMT*)mysql_stmt)->field_count; return stackReturnInt(ret); }
int gsc_memory_int_get() { int memory; int helper = 0; helper += stackGetParamInt(1, &memory); #if DEBUG_MEMORY printf("gsc_memory_int_get(memory=%d)\n", memory); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for gsc_memory_int_get(memory);\n"); return stackReturnInt(0); } int ret = *(int*)memory; return stackReturnInt(ret); }
void gsc_entity_setalive(int id) { // as in isAlive? int isAlive; if ( ! stackGetParams("i", &isAlive)) { printf("scriptengine> ERROR: gsc_player_setalive(): param \"isAlive\"[1] has to be an integer!\n"); stackPushUndefined(); return; } *(char *)(gentities + gentities_size*id + 353) = isAlive; stackReturnInt(1); }
void gsc_player_button_left(int id) { #if COD2_VERSION == COD2_VERSION_1_0 || COD2_VERSION == COD2_VERSION_1_2 || COD2_VERSION == COD2_VERSION_1_3 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x26FD); #elif COD_VERSION == COD4_1_7 || COD_VERSION == COD4_1_7_L unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x2FA7); #else #warning unsigned char *aim_address = (unsigned char *)(NULL); unsigned char *aim_address = (unsigned char *)(NULL); #endif int leftButtonPressed = (*aim_address & 0x81)==0x81; stackReturnInt(leftButtonPressed); }
void gsc_player_button_leanright(int id) { #if COD_VERSION == COD2_1_0 || COD_VERSION == COD2_1_0_1 || COD_VERSION == COD2_1_2 || COD_VERSION == COD2_1_3 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x26E8); #elif COD_VERSION == COD4_1_7 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x2FB4); #else #warning unsigned char *aim_address = (unsigned char *)(NULL); unsigned char *aim_address = (unsigned char *)(NULL); #endif int leanrightButtonPressed = (*aim_address & 0x80)==0x80; stackReturnInt(leanrightButtonPressed); }
int gsc_mysql_stmt_bind_result() { int mysql_stmt; int result; int helper = 0; helper += stackGetParamInt(1, &mysql_stmt); helper += stackGetParamInt(2, &result); #if DEBUG_MYSQL printf_hide("gsc_mysql_stmt_bind_result(mysql_stmt=%d, result=%d)\n", mysql_stmt, result); #endif if (helper != 2) { printf_hide("scriptengine> wrongs args for gsc_mysql_stmt_bind_result(mysql_stmt, result);\n"); return stackReturnInt(0); } int ret = mysql_stmt_bind_result((MYSQL_STMT*)mysql_stmt, (MYSQL_BIND*)result); return stackReturnInt(ret); }
void gsc_player_button_forward(int id) { #if COD2_VERSION == COD2_VERSION_1_0 || COD2_VERSION == COD2_VERSION_1_2 || COD2_VERSION == COD2_VERSION_1_3 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x26FC); #elif COD_VERSION == COD4_1_7 || COD_VERSION == COD4_1_7_L unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x2FA6); #else #warning unsigned char *aim_address = (unsigned char *)(NULL); unsigned char *aim_address = (unsigned char *)(NULL); #endif int forwardButtonPressed = (*aim_address & 0x7F)==0x7F; stackReturnInt(forwardButtonPressed); }
void gsc_player_button_jump(int id) { #if COD2_VERSION == COD2_VERSION_1_0 || COD2_VERSION == COD2_VERSION_1_2 || COD2_VERSION == COD2_VERSION_1_3 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x26E9); #elif COD_VERSION == COD4_1_7 || COD_VERSION == COD4_1_7_L unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x2FB5); #else #warning unsigned char *aim_address = (unsigned char *)(NULL); unsigned char *aim_address = (unsigned char *)(NULL); #endif int jumpButtonPressed = (*aim_address & 0x04)==0x04; stackReturnInt(jumpButtonPressed); }
int gsc_memory_int_set() { int memory; int value; int helper = 0; helper += stackGetParamInt(1, &memory); helper += stackGetParamInt(2, &value); #if DEBUG_MEMORY printf("gsc_memory_int_set(memory=%d, value=%d)\n", memory, value); #endif if (helper != 2) { printf_hide("scriptengine> wrongs args for gsc_memory_int_set(memory, value);\n"); return stackReturnInt(0); } *(int*)memory = value; return stackReturnInt(1); }
void gsc_player_button_back(int id) { #if COD_VERSION == COD2_1_0 || COD_VERSION == COD2_1_0_1 || COD_VERSION == COD2_1_2 || COD_VERSION == COD2_1_3 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x26FC); #elif COD_VERSION == COD4_1_7 unsigned char *aim_address = (unsigned char *)(PLAYERSTATE(id) + 0x2FA6); #else #warning unsigned char *aim_address = (unsigned char *)(NULL); unsigned char *aim_address = (unsigned char *)(NULL); #endif int backButtonPressed = (*aim_address & 0x81)==0x81; stackReturnInt(backButtonPressed); }
int gsc_mysql_stmt_init() { int mysql; int helper = 0; helper += stackGetParamInt(1, &mysql); #if DEBUG_MYSQL printf_hide("gsc_mysql_stmt_init(mysql=%d)\n", mysql); // print as %d, cause i cant print it with hex in .gsc #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for gsc_mysql_stmt_init(mysql);\n"); return stackReturnInt(0); } MYSQL_STMT *stmt; stmt = mysql_stmt_init((MYSQL*)mysql); int ret = (int) stmt; return stackReturnInt(ret); }
int gsc_memory_malloc() { int bytes; int helper = 0; helper += stackGetParamInt(1, &bytes); printf_hide("GANZ NORMALES ASD"); #if DEBUG_MEMORY printf("gsc_memory_malloc(bytes=%d)\n", bytes); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for gsc_memory_malloc(bytes);\n"); return stackReturnInt(0); } int ret = (int) malloc(bytes); return stackReturnInt(ret); }
int gsc_memory_memset() { int memory; int value; int bytes; int helper = 0; helper += stackGetParamInt(1, &memory); helper += stackGetParamInt(2, &value); helper += stackGetParamInt(3, &bytes); #if DEBUG_MEMORY printf("gsc_memory_memset(memory=%d, value=%d, bytes=%d)\n", memory, value, bytes); #endif if (helper != 3) { printf_hide("scriptengine> wrongs args for gsc_memory_memset(memory, value, bytes);\n"); return stackReturnInt(0); } memset((void*)memory, value, bytes); return stackReturnInt(1); }
int gsc_mysql_stmt_prepare() { int mysql_stmt; char *sql; int len; int helper = 0; helper += stackGetParamInt(1, &mysql_stmt); helper += stackGetParamString(2, &sql); helper += stackGetParamInt(3, &len); #if DEBUG_MYSQL printf_hide("gsc_mysql_stmt_prepare(mysql_stmt=%d, sql=%s)\n", mysql_stmt, sql); #endif if (helper != 3) { printf_hide("scriptengine> wrongs args for gsc_mysql_stmt_prepare(mysql_stmt);\n"); return stackReturnInt(0); } int ret = mysql_stmt_prepare((MYSQL_STMT*)mysql_stmt, sql, len); return stackReturnInt(ret); }
void gsc_fpsnextframe() { extern int clfps[64][20]; extern int clfpstemp[64]; extern int clfpsindex; for(int i = 0; i < sizeof(clfpstemp) / sizeof(int); i++) { clfps[i][clfpsindex] = clfpstemp[i]; clfpstemp[i] = 0; } clfpsindex++; if(clfpsindex >= sizeof(clfps[0]) / sizeof(int)) clfpsindex = 0; stackReturnInt(0); }
void gsc_entity_setbounds(int id) { float width, height; if ( ! stackGetParams("ff", &width, &height)) { printf("scriptengine> ERROR: please specify width and height to gsc_entity_setbounds()\n"); stackPushUndefined(); return; } *(float*)(gentities + gentities_size*id + 280) = height; *(float*)(gentities + gentities_size*id + 276) = width; *(float*)(gentities + gentities_size*id + 272) = width; *(float*)(gentities + gentities_size*id + 264) = -width; *(float*)(gentities + gentities_size*id + 260) = -width; printf("id=%d height=%f width=%f\n", id, height, width); stackReturnInt(1); }
void gsc_player_velocity_add(int id) { float velocity[3]; if ( ! stackGetParams("v", &velocity)) { printf("scriptengine> wrongs args for gsc_player_velocity_add(vector velocity);\n"); stackPushUndefined(); return; } float *player_0_velocity_x = (float *)(PLAYERSTATE_VELOCITY(id) + 0); float *player_0_velocity_y = (float *)(PLAYERSTATE_VELOCITY(id) + 4); float *player_0_velocity_z = (float *)(PLAYERSTATE_VELOCITY(id) + 8); *player_0_velocity_x += velocity[0]; *player_0_velocity_y += velocity[1]; *player_0_velocity_z += velocity[2]; stackReturnInt(1); }
int gsc_mysql_affected_rows() { int mysql; int helper = 0; helper += stackGetParamInt(1, &mysql); #if DEBUG_MYSQL printf_hide("gsc_mysql_affected_rows(%d)\n", mysql); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for mysql_affected_rows(mysql);\n"); return stackPushUndefined(); } int ret = mysql_affected_rows((MYSQL *)mysql); return stackReturnInt(ret); }
int gsc_mysql_num_fields() { int result; int helper = 0; helper += stackGetParamInt(1, &result); #if DEBUG_MYSQL printf_hide("gsc_mysql_num_fields(result=%d)\n", result); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for mysql_num_fields(result);\n"); return stackPushUndefined(); } int ret = mysql_num_fields((MYSQL_RES *)result); return stackReturnInt(ret); }
void gsc_player_outofbandprint(int id) { char* cmd; // print\ninsert test message here!!!\n if ( ! stackGetParams("s", &cmd)) { printf("scriptengine> ERROR: gsc_player_outofbandprint(): param \"cmd\"[1] has to be an string!\n"); stackPushUndefined(); return; } #if COD_VERSION == COD2_1_0 int remoteaddress_offset = 452036; #else int remoteaddress_offset = 452308; #endif int info_player = PLAYERBASE(id); netadr_t * from = (netadr_t*)(info_player + remoteaddress_offset); NET_OutOfBandPrint(0, *from, cmd); // 0 = SERVER, 1 = CLIENT stackReturnInt(1); }
int gsc_mysql_query() { int mysql; char *sql; int helper = 0; helper += stackGetParamInt(1, &mysql); helper += stackGetParamString(2, &sql); #if DEBUG_MYSQL printf_hide("gsc_mysql_query(%d, \"%s\")\n", mysql, sql); #endif if (helper != 2) { printf_hide("scriptengine> wrongs args for mysql_query(...);\n"); return stackPushUndefined(); } int ret = mysql_query((MYSQL *)mysql, sql); return stackReturnInt(ret); }
int gsc_mysql_store_result() { int mysql; int helper = 0; helper += stackGetParamInt(1, &mysql); #if DEBUG_MYSQL printf_hide("gsc_mysql_store_result(%d)\n", mysql); #endif if (helper != 1) { printf_hide("scriptengine> wrongs args for mysql_store_result(mysql);\n"); return stackPushUndefined(); } MYSQL_RES *result; result = mysql_store_result((MYSQL *)mysql); int ret = (int) result; return stackReturnInt(ret); }
void gsc_player_connectionlesspacket(int id) { char* cmd; // rcon pass status if ( ! stackGetParams("s", &cmd)) { printf("scriptengine> ERROR: gsc_player_connectionlesspacket(): param \"cmd\"[1] has to be an string!\n"); stackPushUndefined(); return; } char message[1024]; message[0] = -1; message[1] = -1; message[2] = -1; message[3] = -1; message[4] = 0; strcat(message, cmd); msg_t msg; msg.data = message; msg.maxsize = 131072; msg.cursize = strlen(msg.data)+1; msg.readcount = 0; msg.overflowed = false; msg.bit = 0; #if COD_VERSION == COD2_1_0 int remoteaddress_offset = 452036; #else int remoteaddress_offset = 452308; #endif int info_player = PLAYERBASE(id); netadr_t * from = (netadr_t*)(info_player + remoteaddress_offset); SV_ConnectionlessPacket(*from, &msg); stackReturnInt(1); }
void gsc_player_setguid(int id) { int guid; if ( ! stackGetParams("i", &guid)) { printf("scriptengine> ERROR: gsc_player_setguid(): param \"guid\" has to be a int!\n"); stackPushUndefined(); return; } #if COD_VERSION == COD2_1_0 int guid_offset = 0x765F4; #elif COD_VERSION == COD2_1_2 int guid_offset = 0x76704; #elif COD_VERSION == COD2_1_3 int guid_offset = 0xAE704; #else #warning gsc_player_setguid() got no working addresses for guid_offset int guid_offset = 0x0; #endif int cl = PLAYERBASE(id); *(int*)(cl + guid_offset) = guid; stackReturnInt(1); }
int gsc_mysql_test_1() { printf_hide("test 1 10.05.2012 ;D\n"); MYSQL *my; my = mysql_init(NULL); if (my == NULL) { printf_hide("ERROR: mysql_init()\n"); return stackReturnInt(0); } my = mysql_real_connect( my, "127.0.0.1", "kung", "zetatest", "kung_zeta", 3306, NULL, 0 ); if (my == NULL) { printf_hide("ERROR: mysql_real_connect(): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } int id = 10; { const char *sql = "SELECT 1 + ?,1 UNION SELECT 2+?,1 UNION SELECT 3,2 UNION SELECT 4,3"; int ret; MYSQL_STMT *stmt; stmt = mysql_stmt_init(my); printf_hide("stmt->stmt_id = %d\n", stmt->stmt_id); printf_hide("stmt->prefetch_rows = %d\n", stmt->prefetch_rows); printf_hide("stmt->param_count = %d\n", stmt->param_count); printf_hide("stmt->field_count = %d\n", stmt->field_count); if (stmt == NULL) { printf_hide("ERROR: mysql_stmt_init(my): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } ret = mysql_stmt_prepare(stmt, sql, strlen(sql)); if (ret != 0) { printf_hide("ERROR: mysql_stmt_prepare(stmt, sql, strlen(sql)): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } // set by mysql_stmt_prepare, before they are just default-values (0,1,0,0) // printf_hide("stmt->stmt_id = %d\n", stmt->stmt_id); printf_hide("stmt->prefetch_rows = %d\n", stmt->prefetch_rows); // i dont know printf_hide("stmt->param_count = %d\n", stmt->param_count); // "SELECT ?,?" param_count=2 printf_hide("stmt->field_count = %d\n", stmt->field_count); // "SELECT 1,2,3" field_count=3 MYSQL_BIND param[2], result[2]; memset(param, 0, sizeof(param)); memset(result, 0, sizeof(result)); int myNumAddresses[2]; int paramIntA; int paramIntB; int resultIntA; int resultIntB; my_bool is_null[2]; // JUST TO GET THE INFOS FAST :) printf_hide("sizeof(MYSQL_BIND)=%d\n", sizeof(MYSQL_BIND)); printf_hide("MYSQL_TYPE_LONG=%d\n", MYSQL_TYPE_LONG); printf_hide("offsetof(MYSQL_BIND, buffer_type)=%d\n", offsetof(MYSQL_BIND, buffer_type)); printf_hide("offsetof(MYSQL_BIND, buffer)=%d\n", offsetof(MYSQL_BIND, buffer)); printf_hide("offsetof(MYSQL_BIND, is_unsigned)=%d\n", offsetof(MYSQL_BIND, is_unsigned)); printf_hide("offsetof(MYSQL_BIND, is_null)=%d\n", offsetof(MYSQL_BIND, is_null)); printf_hide("offsetof(MYSQL_BIND, length)=%d\n", offsetof(MYSQL_BIND, length)); // BIND PARAM param[0].buffer_type = MYSQL_TYPE_LONG; param[0].buffer = (void*) ¶mIntA; param[0].is_unsigned = 0; param[0].is_null = 0; param[0].length = 0; param[1].buffer_type = MYSQL_TYPE_LONG; param[1].buffer = (void*) ¶mIntB; param[1].is_unsigned = 0; param[1].is_null = 0; param[1].length = 0; ret = mysql_stmt_bind_param(stmt, param); if (ret != 0) { printf_hide("ERROR: mysql_stmt_bind_param(stmt, param): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } // BIND RESULT result[0].buffer_type = MYSQL_TYPE_LONG; result[0].buffer = (void*) &resultIntA; result[0].is_unsigned = 0; result[0].is_null = 0; //&is_null[0]; result[0].length = 0; result[1].buffer_type = MYSQL_TYPE_LONG; result[1].buffer = (void*) &resultIntB; result[1].is_unsigned = 0; result[1].is_null = 0; //&is_null[1]; result[1].length = 0; ret = mysql_stmt_bind_result(stmt, result); if (ret != 0) { printf_hide("ERROR: mysql_stmt_bind_result(stmt, result): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } { paramIntA = 10; paramIntB = 20; ret = mysql_stmt_execute(stmt); if (ret != 0) { printf_hide("ERROR: mysql_stmt_execute(stmt): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } ret = mysql_stmt_store_result(stmt); if (ret != 0) { printf_hide("ERROR: mysql_stmt_store_result(stmt): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } int i=0; while (mysql_stmt_fetch(stmt) == 0) { printf_hide("row[%d] resultIntA=%d resultIntB=%d\n", i, resultIntA, resultIntB); i++; } printf_hide("READED ROWS=%d\n", i); mysql_stmt_free_result(stmt); } #if 0 { paramIntA = 100; paramIntB = 200; ret = mysql_stmt_execute(stmt); if (ret != 0) { printf_hide("ERROR: mysql_stmt_execute(stmt): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } ret = mysql_stmt_store_result(stmt); if (ret != 0) { printf_hide("ERROR: mysql_stmt_store_result(stmt): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } int i=0; while (mysql_stmt_fetch(stmt) == 0) { printf_hide("row[%d] numAddresses[0] = %d\n", i, myNumAddresses[0]); printf_hide("row[%d] numAddresses[1] = %d\n", i, myNumAddresses[1]); i++; } printf_hide("READED ROWS=%d\n", i); mysql_stmt_free_result(stmt); } #endif mysql_stmt_close(stmt); printf_hide("all went ok till here! :)\n"); } //int ret = mysql_query(my, "SELECT 1 as first,2 as second,3 as third UNION SELECT 11,22,33"); int ret = mysql_query(my, "SELECT * FROM players"); if (ret != 0) { printf_hide("ERROR: mysql_query(): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } printf_hide("affected rows: %d\n", mysql_affected_rows(my)); MYSQL_RES *query; query = mysql_store_result(my); if (mysql_errno(my) != 0) /* do not check query==NULL, because thats also the case for like INSERT */ { printf_hide("ERROR: mysql_store_result(my): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } printf_hide("query-num rows: %d\n", mysql_num_rows(query)); printf_hide("spalten im query: %d\n", mysql_num_fields(query)); int numfields = mysql_num_fields(query); MYSQL_FIELD *field; int i; mysql_field_seek(query, 0); for (i=0; i<numfields; i++) { field = mysql_fetch_field(query); printf_hide("%s(%s), ", field->name, field->table); } printf_hide("\n"); MYSQL_ROW row; while (row = mysql_fetch_row(query)) { int i; for (i=0; i<numfields; i++) printf_hide("%s, ", row[i]); printf_hide("\n"); } mysql_free_result(query); mysql_close(my); return stackReturnInt(1337); }
int gsc_mysql_test_0() { printf_hide("c-mysql 22.02.2012 by 123123231\n"); printf_hide("modified to gsc 10.05.2012 by 123123231\n"); MYSQL *my; my = mysql_init(NULL); if (my == NULL) { printf_hide("ERROR: mysql_init()\n"); return stackReturnInt(0); } my = mysql_real_connect( my, "127.0.0.1", "kung", "zetatest", "kung_zeta", 3306, NULL, 0 ); if (my == NULL) { printf_hide("ERROR: mysql_real_connect(): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } //int ret = mysql_query(my, "SELECT 1 as first,2 as second,3 as third UNION SELECT 11,22,33"); int ret = mysql_query(my, "SELECT * FROM players"); if (ret != 0) { printf_hide("ERROR: mysql_query(): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } printf_hide("affected rows: %d\n", mysql_affected_rows(my)); MYSQL_RES *query; query = mysql_store_result(my); if (mysql_errno(my) != 0) /* do not check query==NULL, because thats also the case for like INSERT */ { printf_hide("ERROR: mysql_store_result(my): %d->\"%s\"\n", mysql_errno(my), mysql_error(my)); mysql_close(my); return stackReturnInt(0); } printf_hide("query-num rows: %d\n", mysql_num_rows(query)); printf_hide("spalten im query: %d\n", mysql_num_fields(query)); int numfields = mysql_num_fields(query); MYSQL_FIELD *field; int i; mysql_field_seek(query, 0); for (i=0; i<numfields; i++) { field = mysql_fetch_field(query); printf_hide("%s(%s), ", field->name, field->table); } printf_hide("\n"); MYSQL_ROW row; while (row = mysql_fetch_row(query)) { int i; for (i=0; i<numfields; i++) printf_hide("%s, ", row[i]); printf_hide("\n"); } mysql_free_result(query); mysql_close(my); return stackReturnInt(1); }
// aimButtonPressed (toggleads or +speed/-speed) void gsc_player_button_ads(int id) { int currentPlayer = playerStates + id * sizeOfPlayer; unsigned char *aim_address = (unsigned char *)(currentPlayer + 0x26CD); int aimButtonPressed = *aim_address & 0xF0; // just the first 4 bits tell the state stackReturnInt(aimButtonPressed); }