Vice Underdogs

Scripting => Scripting Support => Topic started by: Shadow on January 14, 2012, 05:56:09 pm

Title: [PAWN - I know you hate it] Heh, PAWNO + HTML workaround ?
Post by: Shadow on January 14, 2012, 05:56:09 pm
Okay, so, I was thinking of a simple way to add a ban, to a html file.


I know it isn't correct, ( I TRIED ) and wanted to make something like this...

PAWNO opens the file "hash.html", and replaces the section with <head> to <head><text>BlaBla was banned by BlaBla</text></head>

 Tried every kind of code, even thought of PAWNO finding the <!CODE> string into the hash.html and then add under it the text, tried with strreplace, and with DINI examples. Couldn't do it.

 This is a kind of code I thought of, tested but don't works.
      The ban command is this ( I KNOW ITS PRIMITIVE ) :

Code: [Select]
    else if(strcmp(cmd,"ban",true) == 0)
{
if(IsPlayerAdmin(playerid))
{
new plr,snick[256];
tmp = strtok(cmdtext, idx), plr = FindPlayerIDFromString(tmp), snick = strtok(cmdtext,idx);
if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c ban [Nick/ID][Reason]");
  else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Unknown player");
else {
Ban(plr);
new str[256];
format(str,sizeof(str),"ADMIN [%s] banned [%s]. Reason [%s]",gPlayers[playerid],gPlayers[plr],cmdtext[strlen(snick)+1]);
SendClientMessageToAll(COLOR_WHITE,str);
SendClientMessage(plr,COLOR_RED,"You have been banned from this server...");
         new string[256];
new year=0,month=0,day=0;
new Hour,Minute,Second;
  getdate(year,month,day);
gettime(Hour,Minute,Second);
/* format(string,sizeof(string),"\r\n%s was banned by Admin %s on %d.%d.%d at %d:%d:%d with the reason: %s",gPlayers[plr],gPlayers[playerid],day,month,year,Hour,Minute,Second,cmdtext[strlen(snick)+1]);*/
         /*new File:file3,File:file8,File:file4,data[256];
     file2 = fopen("Server/hash.html",io_append);
     //file3 = fopen("Server/hash.PART",io_write);
     new io[256]; format(io,256,"<head>%s",string);
     strreplace("<head>",io,io);*/
     
      format(string,sizeof(string),"\r\n%s was banned by Admin %s on %d.%d.%d at %d:%d:%d with the reason: %s",gPlayers[plr],gPlayers[playerid],day,month,year,Hour,Minute,Second,cmdtext[strlen(snick)+1]);
new /*File:file3,*/File:file2,/*,File:file4,*/data[256];
file2 = fopen("Server/hash.html",io_append);
     //file3 = fopen("Server/hash.PART",io_write);
            while(fread(file2,data)) {
            if(strcmp(data, "<!CODE>", true) == 1)
            {
             break;
     new io[256]; format(io,256,"%s\r\n",string);
     strreplace("<!CODE>",string,io);
     fwrite(file2,"<!CODE>");
            }
            }
            fclose(file2);
   
}
}
return 1;
}
Title: Re: [PAWN - I know you hate it] Heh, PAWNO + HTML workaround ?
Post by: stormeus on January 14, 2012, 05:58:08 pm
Use Squirrel and the XML libraries to accomplish this. Trying to do this in Pawn will cause nothing but grief.
Title: Re: [PAWN - I know you hate it] Heh, PAWNO + HTML workaround ?
Post by: Shadow on January 14, 2012, 06:46:45 pm
I just noticed I cannot even copy the file. Results another blank file..
Now, serious, any workaround ?
Title: Re: [PAWN - I know you hate it] Heh, PAWNO + HTML workaround ?
Post by: Zeke on January 14, 2012, 06:51:59 pm
Leave Pawn and do what Storme said.