Author Topic: Showing Varible in Messageclient  (Read 663 times)

In bold is what is broken. When I try to make it messagecient, the %victim just shows up as victim ingame. I've tried using the " @ %victim @ " and it didn't work either :/
Quote
function servercmdGivecash(%client,%amount,%victim)
{
 if(%client.Blockmoney < %amount)
    {
    messageClient(%client,'','\c6You can not give \c2%1\c6 TD you do not have that much.',%amount);
    return;
    }
 if(%amount < 1)
    {
    messageClient(%client,'','\c6You can not give zero or negative TD.');
    return;
    }
    %victim = findClientByName(%victim);
   if(!isobject(%victim))
    {
    messageClient(%client,'','\c6That player does not exist.');
    return;
    }
    %client.Blockmoney-=%amount;
    %victim.Blockmoney+=%amount;
    messageClient(%victim,'','\c6You have recieved \c2%1\c6 TD from %2.',%amount,%client.name);
   messageClient(%client,'','\c6You have Given \c2%1\c6 TD to %victim.',%amount,%client.name);

 }
« Last Edit: August 18, 2008, 04:43:47 PM by tapemaster21 »

you are using the variable %victim two times, first as a string, and then you overwrite the string using the findClientByName() function, so, %victim now is an object, but you are trying to use it as a string again in the messageClient() function, messageClient wants strings, no objects.
Make a seperate variable for the client object of the victim.

you are using the variable %victim two times, first as a string, and then you overwrite the string using the findClientByName() function, so, %victim now is an object, but you are trying to use it as a string again in the messageClient() function, messageClient wants strings, no objects.
Make a seperate variable for the client object of the victim.

Er, no. Use this:

Code: [Select]
function servercmdGivecash(%client,%amount,%victim)
{
 if(%client.Blockmoney < %amount)
    {
    messageClient(%client,'','\c6You can not give \c2%1\c6 TD you do not have that much.',%amount);
    return;
    }
 if(%amount < 1)
    {
    messageClient(%client,'','\c6You can not give zero or negative TD.');
    return;
    }
    %victim = findClientByName(%victim);
   if(!isobject(%victim))
    {
    messageClient(%client,'','\c6That player does not exist.');
    return;
    }
    %client.Blockmoney-=%amount;
    %victim.Blockmoney+=%amount;
    messageClient(%victim,'','\c6You have recieved \c2%1\c6 TD from %2.',%amount,%client.name);
   messageClient(%client,'','\c6You have Given \c2%1\c6 TD to %2.',%amount,%victim.name);

 }