Scripting I need help can you help me please

as @Payzman said , take more time looking on forum with right word , and you will find most of thing you looking for , your answer is already wrote there : https://forum.cfx.re/t/release-car-spawning-via-chat-commands/7761

1 Like

oh sorry ill do that next time

but this is lua isn’t it or is it c#

it’s about Eventhandlers and TriggerClientEvent / TriggerServerEvent , it’s the same in lua or c# , just the way you type it who is different.

1 Like

ok thanks this helps :slight_smile:

in c# for receive event server or client side , you have to create it in your constructor :

class myClass : BaseScript
{
      public myClass()
      {
             EventHandlers["freezePed"] += new Action<dynamic,dynamic>(myReceiveFunc);
      }

     private void myReceiveFunc(dynamic param1,dynamic param2)
     {
         //  Do your stuff here
     }

}

now you have create and event who can receive your param and do something with it.

now for trigger event from server side :

private void myFunctionTrigger()
{
          TriggerClientEvent(player,"nameOfEventClientSide",param1,param2);
}

ps: it’s an overload on the function triggerclientevent who take no player on param (i never use it yet , but i think it will send to anyplayer connect)

on client side for trigger event on server :

private void myFunctionTrigger()
{
          TriggerServerEvent("nameOfEventServerSide",param1,param2);
}

so do I make client file with the first part of code and put other part in server file

thanks I am going to test it out now thanks so much I am very new to scripting just started yesterday you see but this helps me understand it a lot better thanks

of course you have to make 2 different script (dll) , one will run on server side the other on client side .
some function you will found are only server side vice-versa

yes but thanks for this

do I do the code for /freeze or is that already done

you should do it , it’s a simple script to do , best thing for start.
try it , and if it’s not working you can still post your code and getting help.
(i prefer helping people who try something then just requesting script)

yeh but I didn’t know where to start as I’m new to this

ill try and do it now thanks for all your help

I have tried but think I have done something wrong?

false isnt a function it’s a bool , so remove the () ( you told me you have basic knowledge en c# are you ?)

so i guess this is the client side ? what about the dll you put in ref for this ?

yes I knew its a Bool but I looked at the details and according to my book of c# when I was learning it says that would work so it must be wrong

i just tried to do what you are doing , and it work perfectly for me (i do it on server side)

what would work ? to use false(); like this ? noway !

yeh it didn’t work first time for me as I put 2 = like this == instead of 1 =

is this server side did you say sorry for keep asking questions

private void myFunctionTrigger()
{
TriggerServerEvent(“nameOfEventServerSide”,param1,param2);
}