Script Help

Started by KadirYigit, Jun 22, 2020, 11:05 PM

Previous topic - Next topic

KadirYigit

Hello,im a new scripter. Im trying to make a command that using two "text.tointeger();". But probably i have to prove this a lot... So im here.

[spoiler]     if ( cmd == "sms" )
    {
   if(!text)          MessagePlayer("[#008cff][Turkcell]:[#ffffff]Mesaj gonderilmedi. /sms isim mesaj", player );
         local params = split( text ), plr = FindPlayer( params[0] ), reason = text.tointeger();
          MessagePlayer("[#008cff][Turkcell]:[#ffffff]" + player.Name + "nin mesaji:" + reason+".", plr );
          MessagePlayer("[#008cff][Turkcell]:[#ffffff]Mesajiniz iletildi:" + reason+".", player );
                         PlaySoundForPlayer(player, 50032);
                         PlaySoundForPlayer(plr, 50032);
        }[/spoiler]

I just need command like : /sms nickname text

First blank is for Nick,Second for message. Example

/sms yankee stalker misin ?
 

KadirYigit#6161

Razor.

#1
Use GetPlayer, GetTok and NumTok functions.
if ( cmd == "sms" )
{
if ( ! text ) MessagePlayer( "Use: /sms <player/ID> <message>", player );
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "Error: Invalid player.", player );
else
{
local message = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( !message ) MessagePlayer( "Error: no message.", player );
else
{
MessagePlayer( "Message has sent to: " + plr.Name, player );
MessagePlayer( "SMS from: " +player.Name + " - " + message + ".", player );
}
}
}
}

habi

#2
QuoteMessagePlayer( "SMS from: " +player.Name + " - " + message + ".", plr );
and here are some functions. Add these also
function GetTok( string, separator, n, ... )
{
 local m = ( vargv.len() > 0 ) ? vargv[ 0 ] : n, tokenized = split( string, separator ), text = "";

 if ( ( n > tokenized.len() ) || ( n < 1 ) ) return null;

 for ( ; n <= m; n++ )
 {
  text += text == "" ? tokenized[ n - 1 ] : separator + tokenized[ n - 1 ];
 }

 return text;
}

function NumTok( string, separator )
{
 local tokenized = split( string, separator );

 return tokenized.len();
}

function GetPlayer(plr)
{
  if (IsNum(plr))
  {
   plr = FindPlayer(plr.tointeger());
   if (plr) return plr;
   else return 0;
  }
  else
  {
   plr = FindPlayer(plr);
   if (plr) return plr;
   else return 0;
  }
}

KadirYigit

Thank you all ! Its worked.
KadirYigit#6161