// emojis_client
#include "_defines.fos"
#include "sprite.fos"
array<Sprite> emojis;
array<string> emojis_str =
{
"heart", "super", "wink", "angel", "money",
"attack", "fat", "fork", "fucku", "fuckall",
"gone", "knife", "sex", "boom", "dead"
};
uint emoji_pause;
void InitEmojis()
{
uint len = emojis_str.length();
emojis.resize(len);
for(uint i = 0; i < len; i++)
{
emojis[i].Load("emojis\\"+emojis_str[i]+".frm", PATH_ART_INTRFACE);
}
if(emoji_pause < GetTick())
{
CritterCl@ cr = GetChosen();
if(cr.Param[ST_EMOJI] != 0)
RunServerScriptUnsafe("emojis_server@unsafe_SetEmoji", 0, 0, 0, null, null);
}
}
bool Emoji_ClientHandle(string@ message)
{
if(message[0] == ":")
{
//uint found = -1;
if(emoji_pause < GetTick())
{
if(message == ":)")
{
message = ":wink";
}
for(uint d = 0; d < emojis_str.length(); d++)
{
string check = substring(message, 1, emojis_str[d].length());
Message (check + " = " + emojis_str[d] + " : " +d);
if(check == emojis_str[d])
{
RunServerScriptUnsafe("emojis_server@unsafe_SetEmoji", d + 1, int(emojis_str.length()), 0, message, null);
emoji_pause = GetTick() + 7000;
return false;
}
}
}
else return false;
}
else
{
CritterCl@ chosen = GetChosen();
if(chosen.Param[ST_EMOJI] != 0)
RunServerScriptUnsafe("emojis_server@unsafe_SetEmoji", 0, 0, 0, message, null);
}
return true;
}
void Emoji_ClientDrawOnCritter(CritterCl@ cr)
{
uint eId = cr.Param[ST_EMOJI];
if(eId > 0)
{
if(emojis.length() == 0)
{
InitEmojis();
return ;
}
eId--;
int x = 0, y = 0, w = 0, h = 0, lines = 0;
bool nameVisible = false;
cr.GetNameTextInfo(nameVisible, x, y, w, h, lines);
if( x > 0 && y > 0)
{
x -= 5;
y -= 55;
emojis[eId].DrawXY(x, y,50,50);
}
}
}
// emojis_server
#include "_macros.fos"
#include "utils_h.fos"
//#define MAX_EMOJIS 3
void unsafe_SetEmoji(Critter& player, int emojiID, int maxLen, int, string@ message, int[]@)
{
if(emojiID <= maxLen && emojiID > 0)
{
player.ParamBase[ST_EMOJI] = emojiID;
if(valid(player))
{
Log ( GetCritterInfo(player) + " set " + emojiID) ;
uint[] values = { player.Id, emojiID };
CreateTimeEvent ( AFTER(REAL_SECOND(7)), "e_EmojiFunc", values, false);
}
}
else
{
player.ParamBase[ST_EMOJI] = 0;
}
}
uint e_EmojiFunc(uint[]@ values)
{
Critter@ crit = GetCritter(values[0]);
//Log ( GetCritterInfo(crit) + " emoji timer event set zero") ;
if(valid(crit) && uint( crit.ParamBase[ST_EMOJI] ) == values[1])
crit.ParamBase[ST_EMOJI] = 0;
//Log ( GetCritterInfo(crit) + " processed") ;
return 0;
}