Paying ALOT For this to be DONE!
#1

хk i want it so i can /setnotice MESSAGE and then it saves into a .ini or something and then on without restart when a player connect it will show the message in a textdraw where they have the option to ''Dismiss'' it but if i have /setnotice 0 it wont show when the player logs in please help and it also must load on server start and stuff
Reply
#2

How much?
Reply
#3

well it has to be flawless so idk offer
Reply
#4

I'll do this for free for you later on.

Is it alright with a MySQL database?
Reply
#5

igetty no i tried a mysql thing once ended bady haha
Reply
#6

Quote:
Originally Posted by NinjaChicken
Посмотреть сообщение
igetty no i tried a mysql thing once ended bady haha
Dont give it away, keep try
Reply
#7

hahay ea but i made a massive system on flat files
Reply
#8

Well; if you show me how your file system works later, I'll sort it. PM me please.
Reply
#9

Working on It

EDIT :

Done

You will need
  • ZCMD (or you may convert the command to other processor)
  • sscanf
WORKING
Add this to top
pawn Код:
#include <Notice>
Yes this is an include file.

STOCKS

pawn Код:
native Load();
native End();
native ShowNoticeForPlayer(playerid);
native ShowNoticeForAll();
native SetNotice(msg[],playerid=-1);
Add Load() under OngameModeInIt() or maybe under OnFilterScriptInit()
Add End() under OnGameModeExit() or under OnFilterScriptExit()

Load basically load's up the textdraws and End destroy's them.

SetNotice(msg[],playerid=-1)

Here playerid is optional parameter.
It is only used if you want to SendClientMessage that he was able to change notice or not.

pawn Код:
//Example
SetNotice("This is notice Text");
//Set's notice text to "This is notice Text"
ShowNoticeForPlayer(playerid)

It shows the notice for a playerid
pawn Код:
public OnPlayerConnect(playerid)
{
    ShowNoticeForPlayer(playerid);
}
Similar is the working for ShowNoticeForAll();
It will show notice to all players connected.

Some Defines

pawn Код:
#define NoticePath "/Server/notice.ini"
#define MAX_NL 128
NoticePath is the directory where the notice is stored.

MAX_NL is Maximum Length of Notice which is by default at 128.

CODE
pawn Код:
/*native Load();
native End();
native ShowNoticeForPlayer(playerid);
native ShowNoticeForAll();
native SetNotice(msg[],playerid=-1);
*/



#define NoticePath "/Server/notice.ini"
#define MAX_NL 128
new Text:TextdrawNotice;
new Text:TextdrawBack;
new Text:ins;
new notice[MAX_NL];
new bool:changed = false;
new on[MAX_PLAYERS] = -1;
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

stock Load()
{
    TextdrawNotice = TextDrawCreate(280.000000, 184.000000, "This is a new Text");
    TextDrawAlignment(TextdrawNotice, 2);
    TextDrawBackgroundColor(TextdrawNotice, 255);
    TextDrawFont(TextdrawNotice, 1);
    TextDrawLetterSize(TextdrawNotice, 0.400000, 3.000000);
    TextDrawColor(TextdrawNotice, -16776961);
    TextDrawSetOutline(TextdrawNotice, 1);
    TextDrawSetProportional(TextdrawNotice, 1);

    TextdrawBack = TextDrawCreate(0.000000, 0.000000, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
    TextDrawBackgroundColor(TextdrawBack, 255);
    TextDrawFont(TextdrawBack, 1);
    TextDrawLetterSize(TextdrawBack, 0.500000, 3.099999);
    TextDrawColor(TextdrawBack, -1);
    TextDrawSetOutline(TextdrawBack, 0);
    TextDrawSetProportional(TextdrawBack, 1);
    TextDrawSetShadow(TextdrawBack, 1);
    TextDrawUseBox(TextdrawBack, 1);
    TextDrawBoxColor(TextdrawBack, 200);
    TextDrawTextSize(TextdrawBack, 651.000000, 40.000000);

    ins = TextDrawCreate(17.000000, 374.000000, "Press ENTER button to dismiss.");
    TextDrawFont(ins, 1);
    TextDrawLetterSize(ins, 0.249999, 1.000000);
    TextDrawColor(ins, 0xFFFFFFFF);
    TextDrawSetProportional(ins, 1);
    TextDrawSetShadow(ins, 1);
   
    new File:f = fopen(NoticePath, io_read);
    fread(f,notice,MAX_NL);
    fclose(f);
   
    return 1;
}

stock End()
{
    TextDrawDestroy(TextdrawNotice);
    TextDrawDestroy(TextdrawBack);
    TextDrawDestroy(ins);
    return 1;
}

stock SetNotice(msg[],playerid=-1)
{
    if(playerid!=-1)
    {
        if(msg[0] == '0' && msg[1] == '\0')
        {
            SendClientMessage(playerid,-1,"Notice has been disabled.");
        }
        else
        {
            SendClientMessage(playerid,-1,"Notice has been changed.");
        }
    }
    new File:f = fopen(NoticePath, io_write);
    fwrite(f,msg);
    fclose(f);
    changed = true;
    return 1;
}
stock ShowNoticeForPlayer(playerid)
{
   
    if(changed == true)
    {
        new File:f = fopen(NoticePath, io_read);
        fread(f,notice,MAX_NL);
        fclose(f);
    }
    if((notice[0] == '0' && notice[1] == '\0') || notice[1] == '\0') return printf("Unable to show notice for %d as notice is disabled",playerid);
   
    on[playerid] = 1;

    TextDrawSetString(TextdrawNotice,notice);
    TextDrawShowForPlayer(playerid,TextdrawBack);
    TextDrawShowForPlayer(playerid,ins);
    TextDrawShowForPlayer(playerid,TextdrawNotice);
    TogglePlayerSpectating(playerid,true);
    changed = false;
    return 1;
}
stock ShowNoticeForAll()
{
   
    if(changed == true)
    {
        new File:f = fopen(NoticePath, io_read);
        fread(f,notice,MAX_NL);
        fclose(f);
    }
    if((notice[0] == '0' && notice[1] == '\0') || notice[1] == '\0') return printf("Unable to show notice for %d as notice is disabled",playerid);

    for(new playerid = 0;playerid<MAX_PLAYERS;++playerid)
    {
        if(!IsPlayerConnected(playerid)) continue;
        on[playerid] = 1;

        TextDrawSetString(TextdrawNotice,notice);
        TextDrawShowForPlayer(playerid,TextdrawBack);
        TextDrawShowForPlayer(playerid,ins);
        TextDrawShowForPlayer(playerid,TextdrawNotice);
        TogglePlayerSpectating(playerid,true);
    }
    changed = false;

    return 1;
}
CMD:setnotice(playerid,params[])
{
//  if(!IsPlayerAdmin(playerid)) return 0; //You may even add your admin variables
    new msg[MAX_NL];
    if(sscanf(params,"s[MAX_NL]",msg)) return SendClientMessage(playerid,-1,"Usage : /setnotice [MESSAGE]");
    SetNotice(msg,playerid);
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(on[playerid] == 1)
    {
        if(PRESSED(KEY_SECONDARY_ATTACK))
        {
            TextDrawHideForPlayer(playerid,TextdrawNotice);
            TextDrawHideForPlayer(playerid,TextdrawBack);
            TextDrawHideForPlayer(playerid,ins);
            on[playerid] = -1;
            TogglePlayerSpectating(playerid,false);
        }
    }
    return 0;
}
Reply
#10

i think i use ini not sure haha
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)