SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 26/02/2018, 04:33 PM   #181
ball
Huge Clucker
 
ball's Avatar
 
Join Date: Jul 2012
Location: Poznan, Poland
Posts: 288
Reputation: 33
Default Re: Pawn.RakNet

I am trying to get some informations about 3D text labels. After searching RPC arguments, I tried this code

Code:
new lLabelID, lColorID, Float:lX, Float:lY, Float:lZ, Float:lDrawDistance, lUseLOS, lPlayerID, lVehicleID;

BS_ReadValue
(
	bs,
	PR_UINT16, lLabelID,
	PR_INT32, lColorID,
	PR_FLOAT, lX,
	PR_FLOAT, lY,
	PR_FLOAT, lZ,
	PR_FLOAT, lDrawDistance,
	PR_BOOL, lUseLOS,
	PR_UINT16, lPlayerID,
	PR_UINT16, lVehicleID
);
SendClientMessageEx(lString, 200, playerid, -1, "label [%d %d %.1f %.1f %.1f %.2f %d %d %d]", lLabelID, lColorID, lX, lY, lZ, lDrawDistance, lUseLOS, lPlayerID, lVehicleID);
Output
Code:
[18:06:04] label [1025 16777215 0.0 0.0 0.0 15.00 0 -253 9983]
label's ID, color ID, position and draw distance are good, but after draw distance data is false. Arguments to RPC I found there: https://github.com/P3ti/RakSAMP/blob...src/netrpc.cpp

Code:
void ScrCreate3DTextLabel(RPCParameters *rpcParams)
{
	PCHAR Data = reinterpret_cast<PCHAR>(rpcParams->input);
	int iBitLength = rpcParams->numberOfBitsOfData;

	RakNet::BitStream bsData((unsigned char *)Data,(iBitLength/8)+1,false);

	WORD ID;
	CHAR Text[256];
	DWORD dwColor;
	FLOAT vecPos[3];
	FLOAT DrawDistance;
	BYTE UseLOS;
	WORD PlayerID;
	WORD VehicleID;

	bsData.Read((WORD)ID);
	bsData.Read((DWORD)dwColor);
	bsData.Read((FLOAT)vecPos[0]);
	bsData.Read((FLOAT)vecPos[1]);
	bsData.Read((FLOAT)vecPos[2]);
	bsData.Read((FLOAT)DrawDistance);
	bsData.Read((BYTE)UseLOS);
	bsData.Read((WORD)PlayerID);
	bsData.Read((WORD)VehicleID);

	stringCompressor->DecodeString(Text, 256, &bsData);

	if(settings.uiTextLabelsLogging != 0)
	{
		char szCreate3DTextLabelAlert[256];
		sprintf_s(szCreate3DTextLabelAlert, sizeof(szCreate3DTextLabelAlert), "[TEXTLABEL] %d - %s (%X, %.3f, %.3f, %.3f, %.2f, %i, %d, %d)", ID, Text, dwColor, vecPos[0], vecPos[1], vecPos[2], DrawDistance, UseLOS, PlayerID, VehicleID);
		Log(szCreate3DTextLabelAlert);
	}
}
Where I can find actual parameters to most of RPC? I saw Jelly's list of RPC, but there is nothing on Create3DTextLabel.
ball is offline   Reply With Quote
Old 26/02/2018, 06:47 PM   #182
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 543
Reputation: 131
Default Re: Pawn.RakNet

`uselos` type is `byte`, so you have to parse it as `PR_UINT8`.

LE: I don't get why don't you simply hook `Create(Player)3DTextLabel` function instead of going so lowlevel.
Spmn is offline   Reply With Quote
Old 27/02/2018, 09:00 AM   #183
ball
Huge Clucker
 
ball's Avatar
 
Join Date: Jul 2012
Location: Poznan, Poland
Posts: 288
Reputation: 33
Default Re: Pawn.RakNet

Thanks, now all data is true.

Quote:
LE: I don't get why don't you simply hook `Create(Player)3DTextLabel` function instead of going so lowlevel.
I use dynamic labels (label's id id 1025 as you can see above). Simply I wanted to create option for players to hide certain labels if they want, I can't achieve this with function hook. To hide labels (for example, all attached to vehicles) is returning 0 in OnOutcomingRPC when rpcid is 36 (Create3DTextLabel) is the simplest way, I think.

Anyway, thanks for help.
ball is offline   Reply With Quote
Old 10/03/2018, 01:45 PM   #184
Jelly23
Guest
 
Posts: n/a
Default Re: Pawn.RakNet

PHP Code:
//RPCs
#define RPC_ServerJoin (137)
#define RPC_ServerQuit (138)

ShowPlayerOnScoreBoard(playeridtoplayeridbool:show)
{
    if(!
IsPlayerConnected(playerid) || !IsPlayerConnected(toplayerid)) return 0;
    
    new 
BitStream:bs BS_New(), name[MAX_PLAYER_NAME];
    
    
BS_WriteValue(
        
bs,
        
PR_UINT16playerid,
        
PR_UINT81
    
);

    
BS_RPC(bstoplayeridRPC_ServerQuit);
    
BS_Reset(bs);
    
    
GetPlayerName(playeridnamesizeof(name));
    
    
BS_WriteValue(
        
bs,
        
PR_UINT16playerid,
        
PR_INT320,
        
PR_UINT8, !show,
        
PR_UINT8strlen(name),
        
PR_STRINGname
    
);
    
    
BS_RPC(bstoplayeridRPC_ServerJoin);
    
BS_Delete(bs);
    return 
1;

Function snippet. This will show/hide a player from score-board (In-Game) by adding them back as a NPC for 'toplayerid'.

Take into account that hidden players will have their name tags removed for 'toplayerid', that is because they are added back as NPCs. Other than that, everything works fine.
  Reply With Quote
Old 11/04/2018, 05:16 PM   #185
YourShadow
Big Clucker
 
YourShadow's Avatar
 
Join Date: Apr 2016
Posts: 120
Reputation: 236
Default Re: Pawn.RakNet

Added a new tutorial by BrunoBM23.
YourShadow is offline   Reply With Quote
Old 11/04/2018, 05:26 PM   #186
sampkinq
Big Clucker
 
Join Date: Sep 2013
Location: Turkey
Posts: 185
Reputation: 6
Default Re: Pawn.RakNet

Is it possible to execute actors with this plugin?
sampkinq is offline   Reply With Quote
Old 13/04/2018, 12:47 PM   #187
AroseKhanNiazi
High-roller
 
AroseKhanNiazi's Avatar
 
Join Date: Jan 2014
Location: Pakistan
Posts: 1,373
Reputation: 78
Default Re: Pawn.RakNet

How do I read packets data? Like how would I know that data this packet has, what type of bits(8,16, etc).
Pretty confused, I would like to print out a packet example;
const RCON_CALL = 201;

This packet is called when player enter's /rcon
So how do I read data for it?

I would like to know how can I extract RPC id's.
AroseKhanNiazi is offline   Reply With Quote
Old 13/04/2018, 06:40 PM   #188
narwn
Little Clucker
 
Join Date: Oct 2017
Posts: 14
Reputation: 0
Default Re: Pawn.RakNet

Quote:
Originally Posted by AroseKhanNiazi View Post
How do I read packets data? Like how would I know that data this packet has, what type of bits(8,16, etc).
Pretty confused, I would like to print out a packet example;
const RCON_CALL = 201;

This packet is called when player enter's /rcon
So how do I read data for it?

I would like to know how can I extract RPC id's.
http://forum.sa-mp.com/showthread.php?t=652400
narwn is offline   Reply With Quote
Old 13/04/2018, 08:47 PM   #189
AroseKhanNiazi
High-roller
 
AroseKhanNiazi's Avatar
 
Join Date: Jan 2014
Location: Pakistan
Posts: 1,373
Reputation: 78
Default Re: Pawn.RakNet

That doesn't help, like how would I know this function has what data type?
AroseKhanNiazi is offline   Reply With Quote
Old 13/04/2018, 10:08 PM   #190
ball
Huge Clucker
 
ball's Avatar
 
Join Date: Jul 2012
Location: Poznan, Poland
Posts: 288
Reputation: 33
Default Re: Pawn.RakNet

Here you go most of them: http://forum.sa-mp.com/showthread.php?t=649570
It is in spanish/portugese, I can't find this thread in english, although the most important info is readable.

Code:
ID_RCON_COMMAND (ID: 201)
text_length,
cmdtext
I also want to know how to get packet's data from ID_SPECTATOR_SYNC (212), but I can't find anything how to do it.
ball is offline   Reply With Quote
Reply

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
[Tutorial] Pacotes - Pawn.RakNet Jelly23 Lançamentos/Releases 33 23/06/2018 09:49 PM
[Tutorial] Handlers - Pawn.RakNet Jelly23 Tutorials 6 29/01/2018 11:46 PM
[Tutorial] Handlers - Pawn.RakNet Jelly23 Lançamentos/Releases 14 02/01/2018 11:04 PM
[Tutorial] RPC - Pawn.RakNet Jelly23 Tutorials 21 13/12/2017 09:51 PM
[Tutorial] Packets - Pawn.RakNet Jelly23 Tutorials 2 16/11/2017 05:46 PM


All times are GMT. The time now is 05:45 PM.


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