Help! Photon RPC

·҉ dollaz·҉. .

Approved iModder
Original poster
Approved iModder
Mar 26, 2021
159
1,819
193
Somewhere
Does anyone know how to hook RPC methods in a pun2 game?
I tried setting a pointer to the RPC method in the PhotonView class to call a pun method but it didn’t do anything. No crash or anything.

I already have a lot of shit done for photon like kicking players and destroying their objects but I can’t figure out how to call an rpc method

AE7952C4-FA40-4A5D-A8FE-E203438F4AC7.jpeg


This is one of the things I tried

C++:
//public void RPC(string methodName, PhotonPlayer targetPlayer, object[] parameters) { }
void *(*CallRPC)(monoString *method, void *target, void* param) = (void *(*)(monoString *method, void *target, void* param))getRealOffset(RPCOFFSET);

//public override void Kill(int iKillerId = -9999, PhotonMessageInfo info) { }
CallRPC(CreateMonoString("Kill"), me, NULL);
//"me" is a pointer to my photon player
Does anyone know how?
 

derzost2

Platinian
Apr 15, 2022
16
3
3
31
RU
Your first argument must be the context, since you do not have a static function


C++:
void *self_RPC=NULL;

void (*old_CallRPC)(void *instance, monoString *method, void *target, void *param);
void CallRPC(void *instance, monoString *method, void *target, void *param) {
    if (instance!=NULL) self_RPC=instance;
    return old_CallRPC(instance, method, target, param);
}

//Somewhere below
HOOK_LIB("libil2cpp.so", "0x0000000", CallRPC, old_CallRPC);

//call
if (self_RPC!=NULL) CallRPC(self_RPC, CreateMonoString("Kill"), me, NULL);
//or
if (self_RPC!=NULL) old_CallRPC(self_RPC, CreateMonoString("Kill"), me, NULL);
 

Tosilegit

Platinian
Feb 1, 2022
10
1
3
Perttilä
@·҉ dollaz·҉. . Would you be able to help me figure out how to set myself as a masterclient. Have scoured the internet far and wide and havnt found much usefull info
Very late reply, but if you want, for example, to remove or destroy other players you don't have to be a masterclient. You can use method like
C#:
public void DestroyPlayerObjects(int playerId, bool localOnly)
in Networking peer, localOnly to false.

To get masterclient you can try calling
C#:
public static bool SetMasterClient(PhotonPlayer masterclient)
with your PhotonPlayer instance
in PhotonNetwork. No idea if it allows to change it like that tho.