RP commands and usage

Started by SoFahim, Sep 02, 2015, 10:36 AM

Previous topic - Next topic

SoFahim

Hello there,

As you know, I am newbie about Squirrel Scripting . Thats why, i am requesting you for giving me scripted or idea ( how to ) for making come RP commands.

like,
else if ( cmd == "me" )
{
if (status[ player.ID ].IsReg == false) MessagePlayer(RED+"** []: >> "+ORANGE+"You Need To Registered First!",player);
else if ( status[ player.ID ].IsLogged == false ) MessagePlayer(RED+"** []: >> "+ORANGE+"You Need To Logged-In First!",player);
else if ( !player.IsSpawned ) MessagePlayer( RED+"** []: >> "+ORANGE+"First Spawned And Then Use It.", player );
else if ( !text ) MessagePlayer(ORANGE+"Usage: /"+ cmd +" [Text]", player );
else {
Message(RED+"** >> [Me]:-"+player.Name+""+WHITE+""+text+"");
}
}
Result as playername  > Stormeus type > Takes out his gun, Reload ammo and start shooting

Stormeus takes out his gun, Reload ammo and start shooting
Massage give massage in whole chat, But I want this as Massagenear

Can anyone please help me for that?

The reason I have left VC-MP is scripting base + the gameplay.
VC-MP 0.4 released with lots of awesome things but they put pawn behind.

KAKAN

Oh what is RP and what do you mean by saying Massagenear
oh no

DizzasTeR

Create an array which holds all the online players, when someone uses that command, run a foreach loop to go through all the online players, each time a player is taken out from array, check his distance from command user using DistanceFromPoint function and if it in range of certain area then display the message for him using MessagePlayer.

@KAKAN, If you don't know something then just skip the topic ;)

SoFahim

Quote from: KAKAN on Sep 02, 2015, 12:22 PMOh what is RP and what do you mean by saying Massagenear
RP mean RolePlay. the famous mode in GTA gaming.
MassageNear mean massage to near players

Quote from: Doom_Killer on Sep 02, 2015, 12:24 PMCreate an array which holds all the online players, when someone uses that command, run a foreach loop to go through all the online players, each time a player is taken out from array, check his distance from command user using DistanceFromPoint function and if it in range of certain area then display the message for him using MessagePlayer.

@KAKAN, If you don't know something then just skip the topic ;)
Any script example please?

The reason I have left VC-MP is scripting base + the gameplay.
VC-MP 0.4 released with lots of awesome things but they put pawn behind.

KAKAN

Quote from: Doom_Killer on Sep 02, 2015, 12:24 PM@KAKAN, If you don't know something then just skip the topic ;)

From next time I'll
Q- Does SoFahim even know how to do a array and use a foreach loop :p?
oh no

DizzasTeR

#5
Quote from: KAKAN on Sep 02, 2015, 12:30 PM
Quote from: Doom_Killer on Sep 02, 2015, 12:24 PM@KAKAN, If you don't know something then just skip the topic ;)

From next time I'll
Q- Does SoFahim even know how to do a array and use a foreach loop :p?

Do you know how to do it? Post an example for him if you can.

KAKAN

What to do? A example of foreach loop?
Easy
Global variable:-
playerson <- [];

function onPlayerJoin(player)
{
playerson.push(player.ID);
}

function onPlayerPart(player)
{
if(playerson.find(player.ID)!=null )
  {
    local idx = playerson.find(player.ID);
    playerson.remove(idx);
  }
}

An example:-(don't use it)
function onScriptLoad()
{
gate <- CreateObject( 310, 1, -276.618, -495.992, 10.2778, 255 );
NewTimer("gatesystem", 500, 0 );
}

function gatesystem()
{
    local gatestatus = 0;
foreach( playerid, val in playerson ) 
{
        local player = FindPlayer( playerid );
        if ( player )
        {
            if ( player.IsSpawned )
            {
                if ( InPoly( player.Pos.x, player.Pos.y, -276.2,-503.462,-268.675,-502.296,-268.887,-488.42,-276.471,-487.991 ) ) gatestatus = 1;
            }
        }
    }
if ( gatestatus == 1 ) gate.MoveTo( Vector( -268.576, -495.99, 10.2778 ), 2800 );
    else gate.MoveTo( Vector( -276.618, -495.992, 10.2778 ), 2800 );     
}               

idk the meaning of VAL in playerson
Can anyone explain me?
oh no

FinchDon

LoL @KAKAN

@SoFahim I think it is easy I think

You need to do is First FindPlayer local plr then on Player Chat then this
if (DistanceFromPoint( plr, player ) > 6 ) return 0;
else return 1;

Correct?
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

EK.IceFlake

 @FinchDon
You are truly such a noob
neither plr or player is a point FFS
if (DistanceFromPoint( plr.Pos, player.Pos ) > 6) return 0;
else return 1;

FinchDon

so what the fuck i am telling u noob it doesnt mean .Pos he has brain he know what to add i just gave example you Fuc***g stupid pie** of **it
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

Quote from: KAKAN on Sep 02, 2015, 01:32 PMWhat to do? A example of foreach loop?
Easy
Global variable:-
playerson <- [];

function onPlayerJoin(player)
{
playerson.push(player.ID);
}

function onPlayerPart(player)
{
if(playerson.find(player.ID)!=null )
  {
    local idx = playerson.find(player.ID);
    playerson.remove(idx);
  }
}

An example:-(don't use it)
function onScriptLoad()
{
gate <- CreateObject( 310, 1, -276.618, -495.992, 10.2778, 255 );
NewTimer("gatesystem", 500, 0 );
}

function gatesystem()
{
    local gatestatus = 0;
foreach( playerid, val in playerson ) 
{
        local player = FindPlayer( playerid );
        if ( player )
        {
            if ( player.IsSpawned )
            {
                if ( InPoly( player.Pos.x, player.Pos.y, -276.2,-503.462,-268.675,-502.296,-268.887,-488.42,-276.471,-487.991 ) ) gatestatus = 1;
            }
        }
    }
if ( gatestatus == 1 ) gate.MoveTo( Vector( -268.576, -495.99, 10.2778 ), 2800 );
    else gate.MoveTo( Vector( -276.618, -495.992, 10.2778 ), 2800 );     
}               

idk the meaning of VAL in playerson
Can anyone explain me?

You posted a code, but you yourself don't know how it works, Bravo!

Anyway the 'val' is a variable stands for value, it is usually named as val but it can be anything, it holds the value of the array item which is processed most recently and changes according to the loop.

@SoFahim, Use the same playerson array method and the only change you have to do is check distance from the player who typed the command and the rest of the players online, since each player online will be forwarded to you from the loop you can check their distance and send the message accordingly to the close players.

EK.IceFlake

Quote from: FinchDon on Sep 02, 2015, 02:57 PMso what the fuck i am telling u noob it doesnt mean .Pos he has brain he know what to add i just gave example you Fuc***g stupid pie** of **it
Oh great... I helped you out and now you're insulting me? Sign of pure noobness

FinchDon

#12
what ur telling huh? i said already i didnt post perfect i just the function is like that but u ....
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Thijn

Quote from: FinchDon on Sep 02, 2015, 04:09 PMwhat ur telling huh? i said already i didnt post perfect i just the function is like that but u ....
Please... Just stop posting. You post a broken example and then insult people who tell you so. Don't blame the other person because you think people will know how to fix your broken code. You didn't, so neither will other noobs.

Stormeus

It's not really roleplaying unless you use accents. Example should be
QuoteStormeus takes out his gun, Reload ammo and start shooting in a French accent