Help! Photon RPC

·҉ dollaz·҉. .

Awesome Active Platinian
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?
 
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);
 
@·҉ 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.
 
You can of course set yourself SetMasterClient(get_localPlayer());

OR you can use get_isMine from Photon, where-ever it is. If it IS MINE, then you'll pass to yourself, so !get_isMine to pass it to others since it isn't mine so you don't affect yourself. For your RPC parameters, you'll have to create your own Parameters to pass it. This isn't easy as it is.
 
Back
Top Bottom