Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // **NOTICE**
- //You may re-distribute the filterscript or alter its contents
- //without the consent of Capua, the creator of this filterscript.
- //However it is appreciated if you mention the creator if re-distributed.
- #define FILTERSCRIPT
- #include <a_samp>
- #include <a_mysql>
- #include <sscanf2>
- #include <zcmd>
- #define SQL_HOST "changeme"
- #define SQL_USER "changeme"
- #define SQL_PASS "changeme"
- #define SQL_DB "changeme"
- enum PLAYER_INFO
- {
- pName[MAX_PLAYER_NAME],
- };
- new gPlayerInfo[MAX_PLAYERS][PLAYER_INFO];
- new NoFeedBackSpam[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Feedback FS by Capua");
- print("--------------------------------------\n");
- mySQL_init();
- return 1;
- }
- new gHandle;
- stock mySQL_init()
- {
- mysql_debug(1); //mysql debug enabled so we can spot errors etc.'
- gHandle = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
- //we'll create a table named 'feedback' with 3 columns: 'feedback id'...
- //...which can be used to detect how many feedbacks has been sent.
- //then we have sender column just to show who sent the feedback.
- //and message obviously shows the message sent by the sender
- mysql_function_query(gHandle, "CREATE TABLE IF NOT EXISTS `feedback` ( \
- `feedback id` int(11) NOT NULL AUTO_INCREMENT, \
- `sender` varchar(24) NOT NULL, \
- `message` varchar(129) NOT NULL, \
- PRIMARY KEY (`feedback id`) \
- )", false, "SendQuery", "");
- return 1;
- }
- forward SendQuery();
- public SendQuery()
- {
- // callback for queries that don't fetch data
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid,gPlayerInfo[playerid][pName],MAX_PLAYER_NAME);
- return 1;
- }
- CMD:feedback(playerid, params[])
- {
- if(NoFeedBackSpam[playerid] == 1)
- return SendClientMessage(playerid, -1, "Do not spam the feedback function!");
- new feedback[128]; //feedback variable is set to 128 because that's max characters in sa-mp
- if (sscanf(params,"s[128]",feedback))
- return SendClientMessage(playerid,-1,"USAGE: /feedback [text]");
- new query[240];
- //now we'll send the written text into the database
- format(query, sizeof(query), "INSERT INTO feedback (sender,message) VALUES ('%s', '%s')", gPlayerInfo[playerid][pName], feedback);
- mysql_function_query(gHandle, query, false, "OnFeedBackInsert", "");
- SendClientMessage(playerid, -1, "Feedback dispatched! Thank you.");
- NoFeedBackSpam[playerid] = 1;
- //10 seconds until the player can send another feedback
- SetTimer("FeedBackTimer", 10000, 0);
- return 1;
- }
- forward FeedBackTimer();
- public FeedBackTimer()
- {
- new playerid;
- NoFeedBackSpam[playerid] = 0;
- return 1;
- }
- forward OnFeedBackInsert(playerid);
- public OnFeedBackInsert(playerid)
- {
- //and the last thing is to assign an ID for the feedback comment!
- mysql_insert_id();
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement