SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 08/05/2009, 07:18 PM   #1
MarcoNecroX
Big Clucker
 
Join Date: Mar 2009
Posts: 82
Reputation: 0
Default Need an Easy Fs

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
MarcoNecroX is offline  
Old 08/05/2009, 07:24 PM   #2
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: Need an Easy Fs

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;
}
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 08/05/2009, 07:39 PM   #3
MarcoNecroX
Big Clucker
 
Join Date: Mar 2009
Posts: 82
Reputation: 0
Default Re: Need an Easy Fs

thx but.. i don't know how to use it in dcmd
MarcoNecroX is offline  
Old 08/05/2009, 07:56 PM   #4
[nl]daplayer
Huge Clucker
 
Join Date: Dec 2007
Posts: 262
Reputation: 25
Default Re: Need an Easy Fs

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.
[nl]daplayer is offline  
Old 08/05/2009, 09:45 PM   #5
MarcoNecroX
Big Clucker
 
Join Date: Mar 2009
Posts: 82
Reputation: 0
Default Re: Need an Easy Fs

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!!!

MarcoNecroX is offline  
Old 08/05/2009, 10:00 PM   #6
JaYmE
Big Clucker
 
Join Date: Feb 2008
Posts: 152
Reputation: 0
Default Re: Need an Easy Fs

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
JaYmE is offline  
Old 08/05/2009, 11:11 PM   #7
MarcoNecroX
Big Clucker
 
Join Date: Mar 2009
Posts: 82
Reputation: 0
Default Re: Need an Easy Fs

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!
MarcoNecroX is offline  
Old 10/04/2010, 06:32 PM   #8
Cardinaal
Big Clucker
 
Join Date: Apr 2010
Posts: 61
Reputation: 0
Default Re: Need an Easy Fs

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?
Cardinaal is offline  
Old 10/04/2010, 06:45 PM   #9
ruckfules99
Huge Clucker
 
Join Date: Jan 2010
Posts: 466
Reputation: 0
Default Re: Need an Easy Fs

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;
}
ruckfules99 is offline  
Old 10/04/2010, 06:59 PM   #10
Cardinaal
Big Clucker
 
Join Date: Apr 2010
Posts: 61
Reputation: 0
Default Re: Need an Easy Fs

Undefined symbols: cmd, idx, szstring.
HELP
Cardinaal is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very easy! Daniel_June Help Archive 4 05/02/2010 07:16 PM
[Easy] Need help GrilloBR Help Archive 1 19/10/2009 02:17 AM
help plz -easy- Sal_Kings Server Support 12 13/04/2009 01:16 AM
Easy help.. anyone? Shellegg Help Archive 4 19/03/2009 12:12 AM
Very easy but i don't know :S harrold Help Archive 10 27/02/2009 08:35 PM


All times are GMT. The time now is 12:24 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.