SA-MP Forums Archive
invalid string (possibly non-terminated string) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: invalid string (possibly non-terminated string) (/showthread.php?tid=588152)



invalid string (possibly non-terminated string) - Mijata - 06.09.2015

Quote:

include\unitedac_api.inc(9 : error 037: invalid string (possibly non-terminated string)

line 98 : /


Код:
#define DIALOG_WEAPONS_TYPE     1
#define DIALOG_CURRENT_TOTAL    2
#define DIALOG_TEAM_SCORE       3
#define DIALOG_ATT_NAME         4
#define DIALOG_DEF_NAME         5
#define DIALOG_ATT_SCORE        6
#define DIALOG_DEF_SCORE        7
#define DIALOG_WEAPONS_LIMIT    8
#define DIALOG_SET_1            9
#define DIALOG_SET_2            10
#define DIALOG_SET_3            11
#define DIALOG_SET_4            12
#define DIALOG_SET_5            13
#define DIALOG_SET_6            14
#define DIALOG_SET_7            15
#define DIALOG_SET_8            16
#define DIALOG_SET_9            17
#define DIALOG_SET_10           18
#define DIALOG_WAR_RESET        19
#define DIALOG_SERVER_PASS      20
#define DIALOG_LOGIN            21
#define DIALOG_REGISTER         22
#define DIALOG_ADMINS           23
#define DIALOG_CLICK_STATS      24
#define CONFIG_PATH 			"attackdefend/config.ini"
Line 98:-------------------///

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

#undef MAX_PLAYERS
#define MAX_PLAYERS      		50

#define ATTACKER_CHANGES_X      29
#define ATTACKER_CHANGES_Y      0
#define DEFENDER_CHANGES_X      -29
#define DEFENDER_CHANGES_Y      0



AW: invalid string (possibly non-terminated string) - Nero_3D - 06.09.2015

You sure?, define don't case errors

Also is that really line 98 in file "unitedac_api.inc"


Re: invalid string (possibly non-terminated string) - Freezo - 06.09.2015

Its from define MAX_PLAYERS

You forgot to put the number of MAX_PLAYERS


Re: invalid string (possibly non-terminated string) - Variable™ - 06.09.2015

Removed.


Re: invalid string (possibly non-terminated string) - Crayder - 06.09.2015

Quote:
Originally Posted by ._Xavier$$
Посмотреть сообщение
MAX_PLAYERS is Already defined, he should remove it from his code.
Remove #undef MAX_PLAYERS and #define MAX_PLAYERS.
No, he shouldn't remove it. He is redefining the MAX_PLAYERS amount. That is good.

On topic, I don't think you're showing us the right file. Show us the "unitedac_api" file.


Re: invalid string (possibly non-terminated string) - Freezo - 06.09.2015

Nvm, Crayder has answer you ...


Re : invalid string (possibly non-terminated string) - Dutheil - 06.09.2015

An advice, instead of using #define, use enum for your dialogs.
PHP код:
enum
{
    
DIALOG_WEAPONS_TYPE,
    
DIALOG_CURRENT_TOTAL,
    
DIALOG_TEAM_SCORE,
    
DIALOG_ATT_NAME,
    
DIALOG_DEF_NAME,
    
DIALOG_ATT_SCORE,
    
DIALOG_DEF_SCORE,       
    
DIALOG_WEAPONS_LIMIT,
    
DIALOG_SET_1,
    
DIALOG_SET_2,
    
DIALOG_SET_3,
    
DIALOG_SET_4,
    
DIALOG_SET_5,
    
DIALOG_SET_6,
    
DIALOG_SET_7,
    
DIALOG_SET_8,
    
DIALOG_SET_9,
    
DIALOG_SET_10,
    
DIALOG_WAR_RESET,
    
DIALOG_SERVER_PASS,
    
DIALOG_LOGIN,
    
DIALOG_REGISTER,
    
DIALOG_ADMINS,
    
DIALOG_CLICK_STATS




Re: invalid string (possibly non-terminated string) - Mijata - 06.09.2015

unitedac_api.inc


Код:
/*

	Example usage: https://u-army.com/tiger/script/ac2.txt

*/


#include <a_samp>
#include <a_http>

#if defined _unitedac_api_included
	#endinput
#endif
#define _unitedac_api_included

#if !defined _uac_PLUGINS

#define _uac_PLUGINS 0
#define _uac_DEBUG 0

#endif

#if _uac_PLUGINS == 1

#include <sscanf2>
#define QUERY_URL 			"u-army.com/AC_API/pInfo.php"
#define UPDATE_URL          "u-army.com/AC_API/update.php"

#else

#include <strlib>
#define QUERY_URL 			"u-army.com/AC_API/pInfo_.php"
#define UPDATE_URL          "u-army.com/AC_API/update_.php"

#endif

// in hindsight, pretty stupid to have different PHP scripts for with and without plugin, have to keep them now compatibility, can't be FUCKED to change it either.
// (why is there even options for with and without plugin, anyway?)

#include <YSI\y_iterate>
#include <YSI\y_bit>
#include <YSI\y_timers>
#include <YSI\y_hooks>

#define VERSION 1.4

#define THREAD_OFFSET 100
#define FILES 31

#if THREAD_OFFSET > MAX_PLAYERS
	#undef THREAD_OFFSET
	#define THREAD_OFFSET 100 + MAX_PLAYERS
#endif

new Timer:AC_Update;

new BitArray:ACRunning<MAX_PLAYERS>;
new BitArray:HasASI<MAX_PLAYERS>;
new BitArray:HasTrainer<MAX_PLAYERS>;
new BitArray:ACOn<1>;
new BitArray:checkedUpdate<1>;

new bool:Files[MAX_PLAYERS][FILES];

stock bool:AC_Toggle(bool:set);

new fileNames[FILES][50] = {
	!"anim/ped.ifp",             // file_0
    !"data/carmods.dat",         // file_1
    !"data/animgrp.dat",         // file_2
    !"data/melee.dat",           // file_3
    !"data/clothes.dat",         // file_4
    !"data/object.dat",          // file_5
    !"data/default.dat",         // file_6
    !"data/surface.dat",         // file_7
    !"data/default.ide",         // file_8
    !"data/gta.dat",             // file_9
    !"data/surfinfo.dat",        // file_10
    !"data/peds.ide",            // file_11
    !"data/vehicles.ide",        // file_12
    !"data/water.dat",           // file_13
    !"data/txdcut.ide",          // file_14
    !"data/water1.dat",          // file_15
    !"models/coll/weapons.col",  // file_16
    !"data/plants.dat",          // file_17
    !"data/furnitur.dat",        // file_18
    !"data/procobj.dat",         // file_19
    !"data/handling.cfg",        // file_20
    !"models/coll/peds.col",     // file_21
    !"models/coll/vehicles.col", // file_22
    !"samp.saa",                 // file_23
    !"samp.exe",                 // file_24
    !"vorbis.dll",               // file_25
    !"data/pedstats.dat",        // file_26
    !"data/ar_stats.dat",        // file_27
    !"vorbisfile.dll",           // file_28
    !"gta_sa.exe",               // file_29
    !"samp.dll"                  // file_30
    //                              ^^ internal file names for AC

};


hook OnFilterScriptInit()
{
	if(Bit_Get(checkedUpdate, 0) == false) {
		HTTP(THREAD_OFFSET, HTTP_GET, UPDATE_URL, "", "UpdateResponse");
		Bit_Let(checkedUpdate, 0);
		AC_Update = repeat AC_MainUpdate();
		Bit_Vet(ACOn, 0);
	}
	return 1;
}

hook OnGameModeInit() {
    if(Bit_Get(checkedUpdate, 0) == false) {
		HTTP(THREAD_OFFSET, HTTP_GET, UPDATE_URL, "", "UpdateResponse");
		Bit_Let(checkedUpdate, 0);
		AC_Update = repeat AC_MainUpdate();
		Bit_Vet(ACOn, 0);
	}
	return 1;
}

hook OnGameModeExit() {
	stop AC_Update;
	return 1;
}

hook OnFilterScriptExit() {
	stop AC_Update;
	return 1;
}


forward UpdateResponse(index, code, data[]);
public UpdateResponse(index, code, data[]) {
    if(code != 200) {
        HTTP(THREAD_OFFSET, HTTP_GET, UPDATE_URL, "", "UpdateResponse");
	    return printf("United Anti-cheat error: Failed to connect to website API");
	}
	#pragma unused index

	new Float:version = 0.0, url[128];

	#if _uac_PLUGINS == 0

	new str[5][128];
	strexplode(str, data, ",");
	version = floatstr(str[0]);
	url = str[1];

	if(!strlen(url) || version == 0.0) {
	    return printf("United AC Error: Failed to check for an update.");
	}

	#else

	if(sscanf(data, "fs[128]", version, url)) {
	    return printf("United AC Error: Failed to check for an update.");
	}

	#endif

	if(version > VERSION) {
	    printf("__________________________________________________");
	    printf("");
	    printf("** Your United Anti-Cheat API include is out of date, your old version may not continue to work.");
		printf("A new version is available at: %s", url);
		printf("");
		printf("__________________________________________________");

	} else if(!strcmp(url, "- Server not approved for Anti-Cheat usage.")) {
	    printf(data);
	    printf("__________________________________________________");
	    printf("");
	    printf("** Server not approved for [U]nited Anti-cheat Usage, Disabled.");
	    printf("");
	    printf("__________________________________________________");
	} else if(!strcmp(url, "Under Maintenance.")) {
	    printf("__________________________________________________");
	    printf("");
	    printf("** [U]nited Anti-Cheat is current under scheduled maintenance, it cannot be enabled at this time.");
	    printf("");
	    printf("__________________________________________________");
	    AC_Toggle(false);
	} else {
	    printf("__________________________________________________");
	    printf("");
	    printf("** United Army Anti-Cheat is on the most up-to-date version!");
	    printf("");
	    printf("__________________________________________________");
	}
	return 1;
}

hook OnPlayerConnect(playerid)
{
   	AC_GetInfo(playerid);
   	return 1;
}

hook OnPlayerDisconnect(playerid, reason) {

	Bit_Vet(ACRunning, 	playerid);
	Bit_Vet(HasASI, 	playerid);
	Bit_Vet(HasTrainer, playerid);

	for(new i=0; i < FILES; ++i) {
	    Files[i] = true;
	}

	return 1;
}

timer AC_MainUpdate[120000]() {
	if(Bit_Get(ACOn, 0) == true) {
		foreach(new i : Player) {
		    AC_GetInfo(i);
		}
	} else {
		stop AC_Update;
	}
}

stock AC_GetInfo(playerid) {
	if(Bit_Get(ACOn, 0) == true) {
	    new IP[MAX_PLAYER_NAME], url[128], postdata[50];
		GetPlayerIp(playerid, IP, sizeof(IP));
		
		#if _uac_DEBUG == 1
		if(!strcmp(IP, "127.0.0.1", true)) {
			IP = "";
		}
		#endif

	 	format(url, sizeof(url), QUERY_URL);
	 	format(postdata, sizeof(postdata), "IP=%s", IP);
		HTTP(playerid + THREAD_OFFSET, HTTP_POST, url, postdata, "ACResponse");
	}
	return 1;
}



forward ACResponse(index, code, data[]);
public ACResponse(index, code, data[]) {
    if(code != 200) {
        // try again?
        AC_GetInfo(index - THREAD_OFFSET);
	    return printf("United Anti-cheat error: Failed to connect to website API");
	}

	if(strlen(data) > 1) {
		
		if(!strcmp(data, "Under Maintenance")) {
		    printf("__________________________________________________");
		    printf("");
		    printf("** [U]nited Anti-Cheat is current under scheduled maintenance, it cannot be enabled at this time.");
		    printf("");
		    printf("__________________________________________________");
		    AC_Toggle(false);
		    return 1;
		}
		
		#if _uac_DEBUG == 1
		printf(data);
		#endif
		
	    #if _uac_PLUGINS == 1
	    
	    /*if(data[1] != ' ') { // Server not approved for anti-cheat usage.
	        printf(data);
	        AC_Toggle(false);
	        return 1;
	        // hint to the fags looking through this include: removing this if() block won't make anti-cheat work if your server is not approved; it has to be done server-side.
	    }*/
	    // all servers can use AC now without being whitelisted.
	    
		new bool:acrunning, bool:hasasi, bool:hastrainer;
		sscanf(data, "p< >lllA<l>(false)["#FILES"]", acrunning, hasasi, hastrainer, Files[index - THREAD_OFFSET]);

		Bit_Set(ACRunning,  index - THREAD_OFFSET, acrunning);
		Bit_Set(HasASI, 	index - THREAD_OFFSET, hasasi);
		Bit_Set(HasTrainer, index - THREAD_OFFSET, hastrainer
		);
		#else
		
		/*if(data[1] != ',') { // Server not approved for anti-cheat usage.
	        printf(data);
	        AC_Toggle(false);
	        return 1;
	        // hint to the fags looking through this include: removing this if() block won't make anti-cheat work if your server is not approved; it has to be done server-side.
	    }*/
	    // all servers can use AC now without being whitelisted.

		new str[35][20];
		strexplode(str, data, ",");

        Bit_Set(ACRunning,  index - THREAD_OFFSET, strcmp(str[0], "false") == 0 ? false :
																							strcmp(str[0], "0") == 0 ? false : true );
		Bit_Set(HasASI, 	index - THREAD_OFFSET, strcmp(str[1], "false") == 0 ? false :
																							strcmp(str[1], "0") == 0 ? false : true );
		Bit_Set(HasTrainer, index - THREAD_OFFSET, strcmp(str[2], "false") == 0 ? false :
																							strcmp(str[2], "0") == 0 ? false : true );

		for(new i=0; i < FILES; ++i) {
			Files[index - THREAD_OFFSET][i] = strcmp(str[i+3], "false") == 0 ? false : strcmp(str[i+3], "0") == 0 ? false : true;
		}
		#endif


	} else {
		Bit_Vet(ACRunning, index - THREAD_OFFSET);
	}

	// check if they're still connected when the HTTP thread finished.
	if(IsPlayerConnected(index - THREAD_OFFSET)) {
		CallLocalFunction("OnACUpdated", "d", index - THREAD_OFFSET);

		
		for(new i=0; i < FILES; ++i) {
			if(Files[index - THREAD_OFFSET][i] == false && Bit_Get(ACRunning, index - THREAD_OFFSET) == true) {
			    // check if player is connected again (yes, in the loop), in case they got kicked or banned when OnACUpdated got called.
			    if(IsPlayerConnected(index - THREAD_OFFSET)) {
			    	CallLocalFunction("OnACFileModified", "ds", index - THREAD_OFFSET, fileNames[i]);
				}
    		}
		}
	}
	return 0;
}

// for some reason this function doesn't get called in other scripts when this include is included in any script
// something to do with YSI compatability since removing YSI fixes the problem.
// just hook it and do nothing and it will work again.

hook OnPlayerClickTextDraw(playerid, Text:clickedid) { }

#define AC_Running(%0) Bit_Get(ACRunning, %0)
#define AC_HasTrainer(%0) Bit_Get(HasTrainer, %0)
#define AC_ASI(%0) Bit_Get(HasASI, %0)
#define AC_GetEnabled() Bit_Get(ACOn, 0)

stock bool:AC_Toggle(bool:set) {
	Bit_Set(ACOn, 0, set);

	if(set) {
	    AC_MainUpdate();
	    AC_Update = repeat AC_MainUpdate();
	} else {
		stop AC_Update;
	}
	
	CallLocalFunction("OnACToggled", "d", set);
}

forward OnACToggled(bool:set);
forward OnACUpdated(playerid);
forward OnACFileModified(playerid, file[]);