Scritpt Entende que й uma array?
#1

Pessaol eu fiz isso aqui e ele pensa que й uma array

Код:
public CheckConnectionWithTool(tentativas)
{
	for(new i=0; i<tentativas; i++)
	{
		new string[256]; // Create the string to store the read text in
		new File: file = fopen("sampsc/socket.com", io_read); // Open the file
		if (file)
		{
	    	// Le o Comando
	    	fread(file, string); // Fread from the file and store what's read in 'string'
	    	fclose(file); // Close the file
	    	new command[256];
	    	format(command, sizeof(command),"%s",string);
	    	if (command == "CHECKSTATUS")
	    	{
	        	// Envia o Status da COM
	        	new strfile[256];
	        	format(strfile, sizeof(strfile),"SDKOK_RESP001");
	        	new File: file2 = fopen("sampsc/socket.resp", io_write); // Open the file
	        	if (file2)
	       		{
					fremove("sampsc/socket.resp");
	        	}
	        	fwrite(file2, strfile);
	        	fclose(file2);
			}
		}
		return 1;
	}
	return 0;
}
isso й para o meu programa que controla o Server por fora. a funcionalidade sу eu sei?mas preciso que ele leia o arquivo .com e responda com o arquivo .resp, o meu programa irб passar o comando pelo arquivo .com e o fs ira responder com o arquivo .resp!
Reply
#2

Isto deve resolver o seu problema:

pawn Код:
public CheckConnectionWithTool(tentativas)
{
    for(new i=0; i<tentativas; i++)
    {
        new string[256]; // Create the string to store the read text in
        new File: file = fopen("sampsc/socket.com", io_read); // Open the file
        if (file)
        {
            // Le o Comando
            fread(file, string); // Fread from the file and store what's read in 'string'
            fclose(file); // Close the file
            new command[256];
            format(command, sizeof(command),"%s",string);
            if(strcmp(command,"CHECKSTATUS",true)==0) //Strcmp para comparar strings
            {
                // Envia o Status da COM
                new strfile[256];
                format(strfile, sizeof(strfile),"SDKOK_RESP001");
                new File: file2 = fopen("sampsc/socket.resp", io_write); // Open the file
                if (file2)
                {
                    fremove("sampsc/socket.resp");
                }
                fwrite(file2, strfile);
                fclose(file2);
            }
        }
        return 1;
    }
    return 0;
}

Espero ter ajudado
Reply
#3

e Ajudo vlws funciono!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)