Author Topic: How do I send arguments with MessageBoxYesNo?  (Read 901 times)

I have this function (packaged) in my script:

Code: [Select]
function fxDTSBrick::setVehicle(%obj, %data, %client)
{
%vehicleName = trim(%data.uiName);

%title = "Spawn Vehicle";
%message = "<font:palatino linotype:20>Are you sure you want to spawn a<br><font:impact:24>" SPC %vehicleName SPC "<br><font:palatino linotype:20>for $" SPC %cost SPC "?";
%yesServerCmd = 'RPGSetVehicle';

clientCmdMessageBoxYesNo(%title, %message, %yesServerCmd);
}

And this function elsewhere:

Code: [Select]
function serverCmdRPGSetVehicle(%client, %obj, %data)
{
echo("client " @ %client);
echo("obj " @ %obj);
echo("data " @ %data);
}

I want to send the arguments %obj and %data to serverCmdRPGSetVehicle but I'm not sure how to do that with clientCmdMessageBoxYesNo

This probably isn't the best solution but I found a bit of a work around, I'll post it here just in-case anyone has anything to say or stumbles across this in the future


Basically the idea was that I created some new fields for the client itself, gave them some relatively unique names, and then retrieved them later in the serverCmd function
Code: [Select]
function fxDTSBrick::setVehicle(%obj, %data, %client)
{
%client.RPGSetVehicleObj = %obj;
%client.RPGSetVehicleData = %data;

clientCmdMessageBoxYesNo(%title, %message, %yesServerCmd);
}

Code: [Select]
function serverCmdRPGSetVehicle(%client)
{
%obj = %client.RPGSetVehicleObj;
%data = %client.RPGSetVehicleData;

        //code that uses %obj and %data here
}

oh damn yeah i was about to post about that

Code: [Select]
function fxDTSBrick::setVehicle(%obj, %data, %client)
{
%client.RPGSetVehicleObj = %obj;
%client.RPGSetVehicleData = %data;

clientCmdMessageBoxYesNo(%title, %message, %yesServerCmd);
}
So, this code will only work if the server is non-dedicated and will always open the message box for the host and only the host.

fxDTSBrick::setVehicle is a server-sided method while clientCmdMessageBoxYesNo is a client-sided method. To trigger a clientCmd on a specific client, you can use

commandToClient(client, command, args...)

I believe the code you're looking for is

Code: [Select]
function fxDTSBrick::setVehicle(%obj, %data, %client)
{
%client.RPGSetVehicleObj = %obj;
%client.RPGSetVehicleData = %data;

%vehicleName = trim(%data.uiName);

%title = "Spawn Vehicle";
%message = "<font:palatino linotype:20>Are you sure you want to spawn a<br><font:impact:24>" SPC %vehicleName SPC "<br><font:palatino linotype:20>for $" SPC %cost SPC "?";

commandToClient(%client, "messageBoxYesNo", %title, %message, "RPGSetVehicle");
}
« Last Edit: November 11, 2016, 12:55:37 PM by Scout31 »

Whoops, thanks for that. I figured there might some something wrong in that regard.