Raised This Month: $51 Target: $400
 12% 

replacing texts/adding color to them.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 11-09-2015 , 10:00   replacing texts/adding color to them.
Reply With Quote #1

Trying to add a colored prefix to a jumpstats plugin with another plugin, Bacardi made the code I just swapped SM with JS,

Quote:
#include <sourcemod>

public OnPluginStart()
{
HookUserMessage(GetUserMessageId("TextMsg"), TextMsg, true);
}

public Action:TextMsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
if(reliable)
{
new String:buffer[256];
BfReadString(bf, buffer, sizeof(buffer));
if(StrContains(buffer, "\x03[JS]") == 0)
{
new Handle:pack;
CreateDataTimer(0.0, timer_strip, pack);

WritePackCell(pack, playersNum);
for(new i = 0; i < playersNum; i++)
{
WritePackCell(pack, players[i]);
}
WritePackString(pack, buffer);
ResetPack(pack);
return Plugin_Handled;
}
}
return Plugin_Continue;
}

public Action:timer_strip(Handle:timer, Handle:pack)
{
new playersNum = ReadPackCell(pack);
new players[playersNum];

for(new i = 0; i < playersNum; i++)
{
players[i] = ReadPackCell(pack);
}
new String:buffer[256];
ReadPackString(pack, buffer, sizeof(buffer));
ReplaceStringEx(buffer, sizeof(buffer), "[JS]", "\x05[JS]\x01");

new Handle:bf = StartMessage("TextMsg", players, playersNum);
BfWriteString(bf, buffer);
EndMessage();
}
It complied but everytime I jump and its printing the message(Nothin happens to the message no change at all), I get a error in the console,

Quote:
L 11/09/2015 - 15:56:55: [SM] [0] Line 13, C:\steamcmd\csgo\csgo\addons\sourc
emod\scripting\colorjumpstats.sp::TextMsg()
L 11/09/2015 - 15:56:55: [SM] Plugin encountered error 21: Native is not bound
L 11/09/2015 - 15:56:55: [SM] Native "BfReadString" reported:
L 11/09/2015 - 15:56:55: [SM] Displaying call stack trace for plugin "colorjumps
tats.smx":
What did I do wrong?
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-09-2015 , 10:34   Re: replacing texts/adding color to them.
Reply With Quote #2

If this is for CS:GO, CS:GO uses Protobuf usermessages instead of BfRead/BfWrite usermessages.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
'-_-'<3zok<3'-_-'
Senior Member
Join Date: Feb 2010
Location: Norway
Old 11-09-2015 , 10:50   Re: replacing texts/adding color to them.
Reply With Quote #3

its for go yep, tried adding protobuf, no idea if I even did a single thing right here..

Quote:
#include <sourcemod>

public OnPluginStart()
{
HookUserMessage(GetUserMessageId("TextMsg"), TextMsg, true);
}

public Action:TextMsg(UserMsg:msg_id, Handle:pb, const players[], playersNum, bool:reliable, bool:init)
{
if(reliable)
{
new String:buffer[256];
PbReadString(pb, buffer, sizeof(buffer));
if(StrContains(buffer, "\x03[JS]") == 0)
{
new Handle:pack;
CreateDataTimer(0.0, timer_strip, pack);

WritePackCell(pack, playersNum);
for(new i = 0; i < playersNum; i++)
{
WritePackCell(pack, players[i]);
}
WritePackString(pack, buffer);
ResetPack(pack);
return Plugin_Handled;
}
}
return Plugin_Continue;
}

public Action:timer_strip(Handle:timer, Handle:pack)
{
new playersNum = ReadPackCell(pack);
new players[playersNum];

for(new i = 0; i < playersNum; i++)
{
players[i] = ReadPackCell(pack);
}
new String:buffer[256];
ReadPackString(pack, buffer, sizeof(buffer));
ReplaceStringEx(buffer, sizeof(buffer), "[JS]", "\x05[JS]\x01");

new Handle:pb = StartMessage("TextMsg", players, playersNum);
PbWriteString(pb, buffer);
EndMessage();
}
Edit; Resolved, ended up modifying the plugin itself.

Last edited by '-_-'<3zok<3'-_-'; 11-12-2015 at 18:14. Reason: Resolved.
'-_-'<3zok<3'-_-' is offline
Send a message via Skype™ to '-_-'<3zok<3'-_-'
Reply



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

Forum Jump


All times are GMT -4. The time now is 03:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode