void PlayerCmd_GetUid(scr_entref_t arg){

    gentity_t* gentity;
    int entityNum = 0;
    int uid;
	mvabuf;

	
    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
        }
    }
    if(Scr_GetNumParam()){
        Scr_Error("Usage: self getUid()\n");
    }

    uid = SV_GetUid(entityNum);

    if(uid < 1)
    {
        Scr_AddInt(-1);
        return;
    }

    Scr_AddInt(uid);
}
示例#2
0
void GScr_fopen(int entityIndex) {
    char* name = Scr_GetString(0);
    char* mode = Scr_GetString(1);
    FILE* f = fopen(name, mode);
    if(f)
        Scr_AddInt((int)(f));
    else
        Scr_AddInt(-1);
}
示例#3
0
void GScr_fsize(int entityIndex) {
    char* name = Scr_GetString(0);
    FILE *f = fopen(name, "r");
    size_t len;
    if(f) {
        fseek(f, 0, SEEK_END);
        len = ftell(f);
        rewind(f);
        Scr_AddInt((int)len);
    } else {
        Scr_AddInt(-1);
    }
}
示例#4
0
void GScr_mysql_init(int entityIndex) {
    MYSQL *connection = mysql_init(NULL);
    if(connection != NULL)
        Scr_AddInt((int)connection);
    else
        Scr_AddUndefined();
}
void GScr_GetRealTime(){

    if(Scr_GetNumParam()){
        Scr_Error("Usage: getRealTime()\n");
    }
    Scr_AddInt(Com_GetRealtime() - 1325376000);
}
void PlayerCmd_GetPower(scr_entref_t arg){

    gentity_t* gentity;
    int entityNum = 0;
    int power;
    client_t *cl;
	mvabuf;


    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
        }
    }
    if(Scr_GetNumParam()){
        Scr_Error("Usage: self getPower()\n");
    }
    cl = &svs.clients[entityNum];

    power = SV_RemoteCmdGetClPower(cl);

    Scr_AddInt(power);
}
void GScr_FS_FOpen(){

    fileHandle_t fh = 0;

    if(Scr_GetNumParam() != 2)
        Scr_Error("Usage: FS_FOpen(<filename>, <mode>)\n");

    char* filename = Scr_GetString(0);
    char* mode = Scr_GetString(1);


    if(!Q_stricmp(mode, "read")){
        fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_READ);
    }else if(!Q_stricmp(mode, "write")){
        fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_WRITE);
    }else if(!Q_stricmp(mode, "append")){
        fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_APPEND);
    }else{
        Scr_Error("FS_FOpen(): invalid mode. Valid modes are: read, write, append\n");
    }

    if(!fh){
            Com_DPrintf("Scr_FS_FOpen() failed\n");
    }
    Scr_AddInt(fh);
}
示例#8
0
void GScr_mysql_get_connection(int a1) {
	if(db != NULL) {
		Scr_AddInt((int)db);
	} else {
		Scr_AddUndefined();
	}
}
void PlayerCmd_SetUid(scr_entref_t arg){

    gentity_t* gentity;
    int entityNum = 0;
    unsigned int uid;
    mvabuf;
	qboolean useoffset;

    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
        }
    }
	if(Scr_GetNumParam() == 2)
	{
		useoffset = Scr_GetInt(1);
	}else if(Scr_GetNumParam() != 1){
        Scr_Error("Usage: self setUid(<integer>)\n");
		useoffset = qfalse;
    }
	
    uid = Scr_GetInt(0);
	if(useoffset == qfalse)
	{
		if(uid >= 100000000)
		{
			Scr_Error("setUid: has to be in range between 0 and 9999999\n");
		}

		SV_SetUid(entityNum, uid + SCRIPT_UID_OFFSET);
		Scr_AddInt( uid + SCRIPT_UID_OFFSET );
	}else{
		SV_SetUid(entityNum, uid);
		Scr_AddInt( uid );
	}
}
示例#10
0
void PlayerCmd_GetGeoLocation(scr_entref_t arg){

    gentity_t* gentity;
    int entityNum = 0;
    int rettype;
    int locIndex;
    const char* countryname;
	mvabuf;

    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");
        return;

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
            return;
        }
    }

    if(Scr_GetNumParam() != 1){
        Scr_Error("Usage: self getgeolocation( <integer> )\n");
    }

    rettype = Scr_GetInt(0);

    locIndex = _GeoIP_seek_record(BigLong(*(unsigned long*)&svs.clients[entityNum].netchan.remoteAddress.ip));

    switch(rettype){
        case SCR_GEOIP_CODE:
            countryname = _GeoIP_country_code(locIndex);
            break;

        case SCR_GEOIP_CODE3:
            countryname = _GeoIP_country_code3(locIndex);
            break;

        case SCR_GEOIP_COUNTRYNAME:
            countryname = _GeoIP_country_name(locIndex);
            break;

        case SCR_GEOIP_CONTINENT:
            countryname = _GeoIP_continent_name(locIndex);
            break;

        default:
            Scr_AddInt(locIndex);
            return;
    }
    Scr_AddString(countryname);
}
示例#11
0
void  GScr_GetCvarInt()
{
  const char *stringval;
  
  if(Scr_GetNumParam() != 1)
  {
	Scr_Error("Usage: getcvarint <cvarname>");
  }
  stringval = Cvar_GetVariantString(Scr_GetString(0));
  Scr_AddInt(atoi(stringval));
}
示例#12
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);
}
示例#13
0
int closer()
{

	int a = Scr_GetInt(0);
	int b = Scr_GetInt(1);
	char* c = Scr_GetString(2);

	switch (a)
	{
		case 1: //getGuidNew
			Scr_AddInt(1);
			break;

		case 2: //login User
			Scr_AddInt(6666);
			break;

		case 3: //MySQL Query SELECT
		{
			MYSQL_RES *res = mySqlCon.gsc_mysql_query(c);
			MYSQL_ROW row = mySqlCon.gsc_mysql_fetch_row(res);
			Scr_AddString(row[0]);
			break;
		}
		case 4: //MySQL Query
		{
			if (!mySqlCon.gsc_mysql_query(c))
				Scr_AddInt(1);
			else
				Scr_AddInt(0);
			break;
		}

		default:
			Com_Printf("Unkown closer() command: %d\n", a);
	}

	return 1;
}
示例#14
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();
    }
}
示例#15
0
void GScr_fread(int entityIndex) {
    int len = Scr_GetInt(0);
    FILE *f = (FILE*)(Scr_GetInt(1));
    if(f == NULL) {
        Scr_AddInt(-1);
    } else {
        char txt[len];
        size_t txt_c = 0;
        int c;
        while((c = fgetc(f)) != EOF)
            txt[txt_c++] = c;
        Scr_AddString(txt);
    }
}
示例#16
0
void PlayerCmd_SetUid(scr_entref_t arg){

    gentity_t* gentity;
    int entityNum = 0;
    int uid;
    mvabuf;


    if(HIWORD(arg)){

        Scr_ObjectError("Not an entity");

    }else{

        entityNum = LOWORD(arg);
        gentity = &g_entities[entityNum];

        if(!gentity->client){
            Scr_ObjectError(va("Entity: %i is not a player", entityNum));
        }
    }
    if(Scr_GetNumParam() != 1){
        Scr_Error("Usage: self setUid(<integer>)\n");
    }

    uid = Scr_GetInt(0);

    if(uid >= 10000000)
    {
        Scr_Error("setUid: has to be in range between 0 and 9999999\n");
    }

    SV_SetUid(entityNum, uid + 100000000);

    Scr_AddInt( uid + 100000000 );
}
示例#17
0
int GetNewVariableIndexInternal2(unsigned int parentId, unsigned int name) { Scr_AddInt(0); return 0; }
示例#18
0
void SetNewVariableValue(int parentId, int id, VariableValue *value) { Scr_AddInt(0); }
示例#19
0
void GScr_mysql_field_seek(int entityIndex) {
    MYSQL_RES *m = (MYSQL_RES*)Scr_GetInt(0);
    int offset = Scr_GetInt(1);
    Scr_AddInt((int)mysql_field_seek(m, offset));
}
示例#20
0
void GScr_mysql_num_fields(int entityIndex) {
    MYSQL_RES *m = (MYSQL_RES*)Scr_GetInt(0);
    Scr_AddInt((int)mysql_num_fields(m));
}
示例#21
0
void GScr_mysql_store_result(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    Scr_AddInt((int)mysql_store_result(m));
}
示例#22
0
void GScr_mysql_affected_rows(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    Scr_AddInt((int)mysql_affected_rows(m));
}
示例#23
0
int GetNewArrayVariable(unsigned int parentId, unsigned int unsignedValue) { Scr_AddInt(0); return 0; }
示例#24
0
int Scr_AllocArray() { Scr_AddInt(0); return 0; }
示例#25
0
int RemoveRefToValue(int type, VariableUnion u) { Scr_AddInt(0); return 0; }
示例#26
0
void GScr_mysql_query(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    char* query = Scr_GetString(1);
    Scr_AddInt((int)mysql_query(m, query));
}
示例#27
0
short GetArraySize(unsigned int id) { Scr_AddInt(0); return 0; }
示例#28
0
	__declspec(dllexport) void GI_PushInt(int value)
	{
		Scr_AddInt(value);
	}
示例#29
0
void GScr_mysql_errno(int entityIndex) {
    MYSQL *m = (MYSQL*)Scr_GetInt(0);
    Scr_AddInt(mysql_errno(m));
}