SA-MP Forums Archive
help with a cmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with a cmd (/showthread.php?tid=646407)



help with a cmd - NitroZeth - 16.12.2017

Hello, who could help me to make a command, that when I speak only see the people who are driving a car and so the passenger like
for example: /r Hello /r [Text]
That ''Hello'' is seen by people who are in a car, who could help me? or do that command


Re: help with a cmd - Konstantinos - 16.12.2017

Step 1: Check if player in vehicle and store the vehicleid.
Step 2: A player-loop.
Step 3: Check if the value of the loop is in the same vehicle: IsPlayerInVehicle or if GetPlayerVehicleID matches.
Step 4: If they are, send the message.


Re: help with a cmd - NitroZeth - 16.12.2017

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Step 1: Check if player in vehicle and store the vehicleid.
Step 2: A player-loop.
Step 3: Check if the value of the loop is in the same vehicle: IsPlayerInVehicle or if GetPlayerVehicleID matches.
Step 4: If they are, send the message.
I'm noob in pwn , can you make cmd pls?


Re: help with a cmd - Konstantinos - 16.12.2017

https://sampwiki.blast.hk/wiki/GetPlayerPoolSize
https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
https://sampwiki.blast.hk/wiki/IsPlayerInVehicle

You should at least try. I'll just give you the core:
pawn Код:
// check if player is not in vehicle and return an error..

// format the text you're going to send to passengers/driver of vehicle

new vehicleid = GetPlayerVehicleID(playerid);

for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
    if (IsPlayerInVehicle(i, vehicleid))
    {
        SendClientMessage(i, color_here, message_here);
    }
}



Re: help with a cmd - AlexMSK - 16.12.2017

PHP код:

CMD
:r(playeridparams[])
{
    new
    
string[144];
    
format(stringsizeof(string), "%s:  %s"GetPlayerName(playerid), params);
    
SendPlayerMessage(playerid20.0string0xAFAFAFAA0xAFAFAFAA0xAFAFAFAA0xAFAFAFAA0xAFAFAFAA);
    return 
1;
}
SendPlayerMessage(playeridFloat:radius, const text[], color1color2color3color4color5)
{
    foreach(new 
Player)
    {
        if(
IsPlayerInAnyVehicle(i))
        {
            if(
IsNearPlayer(iplayeridradius 16))
            {
                
SendClientMessage(icolor1text);
            }
            else if(
IsNearPlayer(iplayeridradius 8))
            {
                
SendClientMessage(icolor2text);
            }
            else if(
IsNearPlayer(iplayeridradius 4))
            {
                
SendClientMessage(icolor3text);
            }
            else if(
IsNearPlayer(iplayeridradius 2))
            {
                
SendClientMessage(icolor4text);
            }
            else if(
IsNearPlayer(iplayeridradius))
            {
                
SendClientMessage(icolor5text);
            }
        }
    }
}
IsNearPlayer(playeridtargetidFloat:radius)
{
    new
        
Float:x,
        
Float:y,
        
Float:z;
    
GetPlayerPos(targetidxyz);
    if(
IsPlayerInRangeOfPoint(playeridradiusxyz) && GetPlayerInterior(playerid) == GetPlayerInterior(targetid) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid))
    {
        return 
1;
    }
    return 
0;

Something like this, if im not wrong.