SA-MP Forums Archive
Scritpt Entende que й uma array? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: Scritpt Entende que й uma array? (/showthread.php?tid=201126)



Scritpt Entende que й uma array? - mafelis - 20.12.2010

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!


Re: Scritpt Entende que й uma array? - rjjj - 20.12.2010

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


Re: Scritpt Entende que й uma array? - mafelis - 20.12.2010

e Ajudo vlws funciono!