Need an Easy Fs
#1

Hi to all I need a FS that has a /suggest [Text] option.

In a file called "suggestions" in the scriptfiles folder, thereshould appear all suggestions with date (or not), one under the another

Thanx for help
Reply
#2

This should be in Script Request however... Try this (I havnt scripted in a while so it might not work )
pawn Code:
stock Log(const string[])
{
  new File:log;
  log = fopen("suggest.log",io_append);
  fwrite(log, string);
  fclose(log);
  return 1;
}
Reply
#3

thx but.. i don't know how to use it in dcmd
Reply
#4

Quote:
Originally Posted by [MFC
Sylar [[::TheMafia::]] ]
thx but.. i don't know how to use it in dcmd
pawn Code:
dcmd_suggest(playerid, params[])
{
  new string[128];
  if (sscanf(params, "s", string)) SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /suggest [text]");
  else
  {
    new File:handle = fopen("suggestions.txt", io_append);
    format(string, 128, "%s\r\n", string);
    fwrite(handle, string);
    fclose(handle);
    SendClientMessage(playerid, 0xC0C0C0FF, "Suggestion Send");
  }
  return 1;
}
I Aspect That you have sscanf in your code.
You need to create a file named "suggestions.txt" in your scriptfiles folder.

Note: Not Tested, And not compiled.
Reply
#5

Hi, thank you.

I changed it, and it works perfect:

Code:
dcmd_suggest(playerid, params[])
{
  new string[128];
  if (sscanf(params, "s", string))
  {
   new File:handle = fopen("suggestions.txt", io_append);
   format(string, 128, "%s\r\n", string);
   fwrite(handle, string);
   fclose(handle);
   SendClientMessage(playerid, 0xC0C0C0FF, "Suggestion Send");
	}
  else
  {
	SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /suggest [text]");
  }
  return 1;
}
But i still have a question, i want to add theese params in the TXT File:

|%s/%s|%s:%s|%s: %s |(%s)| (day, month, hour, minute, player, message, IP)

How can i set that? it would be like this:

|8/5|10:46|[MFC]Sylar: I suggest blah blah |(127.0.0.1)|

Thanx a lot!!!

Reply
#6

Try

pawn Code:
dcmd_suggest(playerid, params[])
{
  new string[128];
  if (sscanf(params, "s", string))
  {
    new File:handle = fopen("suggestions.txt", io_append);
    new Year, Month, Day, Hour, Min, Sec, pName[25], pIP[20];
    GetDate(Month, Day, Hour);
    GetTime(Day, Min, Sec);
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerIp(playerid, pIP, sizeof(pIP));
    format(string, 128, "|%d/%d|%d:%d|%s: %s|(%s)|\r\n", Day, Month, Hour, Min, pName, string, pIP);
    fwrite(handle, string);
    fclose(handle);
    SendClientMessage(playerid, 0xC0C0C0FF, "Suggestion Send");
  }
  else
  {
    SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /suggest [text]");
  }
  return 1;
}
Should work
Reply
#7

Finally got it working :

Code:
//======[Script/GM Beggining]=======//
.....

//======[CommandText]===========//

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(suggest,7,cmdtext);
}

//======[DCMD Command]=========//

dcmd_suggest(playerid, params[])
{
  new string[128];
  if (sscanf(params, "s", string))
  {
    new File:handle = fopen("suggestions.txt", io_append);
    new Month, Day, Hour, Minute, Second, Year, pName[25], pIP[20];
    gettime(Hour, Minute, Second);
    getdate(Year, Month, Day);
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerIp(playerid, pIP, sizeof(pIP));
    format(string, 128, "|%d/%d|%d:%d|%s: %s |(%s)|\r\n", Day, Month, Hour, Minute, pName, string, pIP);
    fwrite(handle, string);
    fclose(handle);
    SendClientMessage(playerid, 0xC0C0C0FF, "Suggestion Send!");
  }
  else
  {
    SendClientMessage(playerid, 0xC0C0C0FF, "USAGE: /suggest [suggestions/whatever]");
  }
  return 1;
}

//======[Script/GM End]=============//
Also create a file called "suggestions.txt" in the Scripfiles folder, and here I tested it:

Code:
|8/5|20:0|[MFC]Sylar: Thank You for the Help! |(127.0.0.1)|
|8/5|20:1|[MFC]Sylar: blablablabla |(127.0.0.1)|
|8/5|20:1|[MFC]Sylar: Goodbye |(127.0.0.1)|
_______________________________

@ JaYmE:

The code you gave me didin't work, i changed somethings and solved the errors, thank you for the code , for example "GetTime(Day, Min, Sec)" has no sence at all, i changed it to "GetTime(Hour, Minute, Second);".

Goodbye!
Reply
#8

Hey sorry for posting in this old topic.
I tried to use that script.
It saves alright.
The problem is when i type: /suggest.. It replies Suggestion Sent! and saves a empy suggestion in suggestions.txt
but when i type /suggest Better streamer(example) it replies: USAGE: /suggest [text].
I don't know how to fix that, sorry.
It should reply: USAGE /suggest [text] if you type only /suggest
But now it replies USAGE /suggest [text] if you type /suggest You need this bla bla bla
Help please?
Reply
#9

Quote:
Originally Posted by Cardinaal
Hey sorry for posting in this old topic.
I tried to use that script.
It saves alright.
The problem is when i type: /suggest.. It replies Suggestion Sent! and saves a empy suggestion in suggestions.txt
but when i type /suggest Better streamer(example) it replies: USAGE: /suggest [text].
I don't know how to fix that, sorry.
It should reply: USAGE /suggest [text] if you type only /suggest
But now it replies USAGE /suggest [text] if you type /suggest You need this bla bla bla
Help please?

Here is a perfect one without any errors. Also, It posts the players name and the IP of the player who /suggest a command so if they abuse it, you can warn them about it.

Code:
if(strcmp(cmd, "/suggest", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_BLUE, "USAGE: /suggest [text]");
return 1;
}
new ip[16]; GetPlayerIp(playerid, ip, sizeof(ip));
format(szstring, sizeof(szstring), "name: %s, IP: %s, Suggestion: %s.",sendername,ip,(result));
SendClientMessage(playerid, COLOR_YELLOW, szstring);
Suggestions(szstring);
}
return 1;
}
Reply
#10

Undefined symbols: cmd, idx, szstring.
HELP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)