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?
Oh what is RP and what do you mean by saying Massagenear
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 ;)
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?
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?
Quote from: KAKAN on Sep 02, 2015, 12:30 PMQuote 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.
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?
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?
@FinchDonYou 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;
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
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.
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
what ur telling huh? i said already i didnt post perfect i just the function is like that but u ....
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.
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
sorry for this post..
But can anyone tell me how to use sphere.StreamedToPlayer(player) function
Exactly like that. I've posted some info about that on the forum before, search for it.
Quote from: Stormeus on Sep 02, 2015, 05:50 PMIt'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
Accent is not fact, In roleplay, accent is not much care. RP depend on role of a player.
In my SAMP roleplay server, I use Proxdetector function to use foreach.
forward ProxDetector(Float:radi, playerid, str[], col1, col2, col3, col4, col5);
public ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
//radi = 2.0; //Trigger Radius
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(i, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, str);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, str);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, str);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, str);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, str);
}
}
}
}//not connected
return 1;
}
and the command is
CMD:me(playerid, params[])
{
if(gPlayerLogged{playerid} == 0)
{
SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
return 1;
}
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /me [action]");
if(strlen(params) > 128)
{
new firstline[128], secondline[128];
strmid(firstline, params, 0, 126);
strmid(secondline, params, 126, 205);
format(secondline, sizeof(secondline), "... %s", secondline);
format(firstline, sizeof(firstline), "* %s %s ...", GetPlayerNameEx(playerid), firstline);
ProxDetector(30.0, playerid, firstline, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
ProxDetector(30.0, playerid, secondline, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else {
new string[128];
format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), params);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
return 1;
}
I know Pawno and Squirrel fully different. and also, I am not well know about SQ. .
I have been confused to make the loop. Can you please give me example code for it. no tlike before one. That one not even about any loop
I have posted the way to use loop, with playerson
here's the default loop we use for max things
for( local i = 0; i < GetMaxPlayers(); i++ )
@SoFahim,
Me command limited to specific distance (http://forum.vc-mp.org/?topic=1394.0)
You can't bloat around your French charm and get away with shit. That's power gaming.
**Stormeus round-house kicks Havana and brings peace and prosperity to Haitians in a French accent (S/F?)