void GScr_FS_ReadLine(){
    char buffer[2048];
    int ret;

    if(Scr_GetNumParam() != 1)
        Scr_Error("Usage: FS_ReadLine(<filehandle>)\n");

    fileHandle_t fh = Scr_GetInt(0);

    *buffer = 0;

    ret = Scr_FS_ReadLine(buffer, sizeof(buffer), fh);
    if(ret < 1 )
        Scr_AddUndefined();

    else if(*buffer == 0)
        Scr_AddString("");

    else{
        int len = strlen(buffer);

        if(buffer[len -1] == '\n')
            buffer[len -1] = 0;

        Scr_AddString(buffer);
    }
}
示例#2
0
void GScr_mysql_init(int entityIndex) {
    MYSQL *connection = mysql_init(NULL);
    if(connection != NULL)
        Scr_AddInt((int)connection);
    else
        Scr_AddUndefined();
}
示例#3
0
void GScr_mysql_get_connection(int a1) {
	if(db != NULL) {
		Scr_AddInt((int)db);
	} else {
		Scr_AddUndefined();
	}
}
示例#4
0
void GScr_mysql_fetch_field(int entityIndex) {
    MYSQL_RES *res = (MYSQL_RES*)Scr_GetInt(0);
    MYSQL_FIELD *f = mysql_fetch_field(res);
    if(!f)
        Scr_AddUndefined();
    else
        Scr_AddString(f->name);
}
void ScrCmd_setTakeDamage(int entityIndex) {
    Entity *ent = game->getEntity(entityIndex);
    if(ent) {
        int take = Scr_GetInt(0);
        ent->set(EOFF.TAKEDAMAGE, take);
    }
    Scr_AddUndefined();
}
示例#6
0
void GScr_mysql_fetch_row(int a1) {
	MYSQL_RES* result = (MYSQL_RES*)Scr_GetInt(0);
	MYSQL_ROW row = mysql_fetch_row(result);
	if (!row) {
		Scr_AddUndefined();
		return;
	}

	Scr_MakeArray();
	
	int num = mysql_num_fields(result);
	for (int i = 0; i < num; i++) {
		if (row[i] == NULL)
			Scr_AddUndefined();
		else
			Scr_AddString(row[i]);
		Scr_AddArray();
	}
}
示例#7
0
void playerDamage(gentity_s* self, gentity_s* attacker, int32_t damage, meansOfDeath_t mod, int32_t weapon, hitLocation_t hitLoc)
{
	//player_die(self, attacker, attacker, damage, mod, weapon, 0, hitLoc, 0);
	char weapName[0x400];

	Scr_AddInt(SCRIPTINSTANCE_SERVER, 0); //boneIndex
	Scr_AddInt(SCRIPTINSTANCE_SERVER, 0); //timeOffset
	Scr_AddConstString(SCRIPTINSTANCE_SERVER, G_GetHitLocationString(hitLoc)); //hitLoc
	Scr_AddUndefined(SCRIPTINSTANCE_SERVER); //vDir
	Scr_AddUndefined(SCRIPTINSTANCE_SERVER); //vPoint
	BG_WeaponName(weapon, weapName, sizeof(weapName));
	DBGPRINTF("weaponName: %s\n", weapName);
	Scr_AddString(SCRIPTINSTANCE_SERVER, weapName); //weapon
	Scr_AddConstString(SCRIPTINSTANCE_SERVER, *modNames[mod]); //meansOfDeath
	Scr_AddInt(SCRIPTINSTANCE_SERVER, 0); //dflags
	Scr_AddInt(SCRIPTINSTANCE_SERVER, damage); //damage
	Scr_AddEntity(SCRIPTINSTANCE_SERVER, attacker); //attacker
	Scr_AddEntity(SCRIPTINSTANCE_SERVER, attacker); //inflictor
	execEntThread(self, g_scr_data->gametype.playerdamage, 11);
}
示例#8
0
void GScr_mysql_real_connect(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    char* hostname = Scr_GetString(1);
    char* username = Scr_GetString(2);
    char* password = Scr_GetString(3);
    char* database = Scr_GetString(4);
    int port = Scr_GetInt(5);
    if(m != NULL) {
        MYSQL *c = mysql_real_connect(m, hostname, username, password, database, port, NULL, 0);
        Scr_AddInt((int)c);
    } else {
        Scr_AddUndefined();
    }
}
示例#9
0
void GScr_mysql_close(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    mysql_close(m);
    Scr_AddUndefined();
}
示例#10
0
void GScr_mysql_free_result(int entityIndex) {
    MYSQL_RES *res = (MYSQL_RES*)Scr_GetInt(0);
    mysql_free_result(res);
    Scr_AddUndefined();
}