UnitSeven Posted April 3, 2021 Share Posted April 3, 2021 How to create custom event in one script (ServerSide) and cal it from another (ServerSide) script. Rage 1.1 Thank you for you time. Link to comment Share on other sites More sharing options...
Kopra Posted April 3, 2021 Share Posted April 3, 2021 (edited) Download some resources from ragemp forum and experiment. Here is an example from one of my gamemodes // Client side class LoginRegister : Events.Script { public LoginRegister() { // this event you call from CEF to get login data using mp.trigger('client:login.player', email, password); Events.Add("client:login.player", LoginPlayerEvent); } private void LoginPlayerEvent(object[] args) { string inputedEmail = (string)args[0], inputedPassword = (string)args[1]; Events.CallRemote("server:login.player", inputedEmail, inputedPassword); } } // Server side [RemoteEvent("server:login.player")] public void LoginPlayerEvent(Player player, string email, string password) { // Check if email and password match if(Database.LoginAccount(email, password)) { // Load all the player data var character = Database.LoadAccountFromEmail(email); LoadCharacterData(player, character); } else { // Warn the player that his email/password is incorrect player.TriggerEvent("javascript:warning", "Wrong username/password."); } } Edited April 3, 2021 by Kopra Link to comment Share on other sites More sharing options...
UnitSeven Posted April 3, 2021 Author Share Posted April 3, 2021 Thank you Kopra for your time and reply. But mine proble is that i want event that i call from another serverside script. If i register RemoteEvent then (i think) i cant call it from another server side script. I tryed to use GTANetworkApi.NAPI.LocalEvent.Register but get no luck with that... propably my skill in C# to low. System.Reflection.MethodInfo zMethod = this.GetType().GetMethod("ClassMethod"); GTANetworkAPI.NAPI.LocalEvent.Register(zMethod, "ClassMethodEvent", this); GTANetworkAPI.NAPI.LocalEvent.TriggerEvent("ClassMethodEvent"); I get System.NullRefenceException on TriggerEvent. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now