Adding "y" to enter/exit the properties[REP++]
#1

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
idx;
    new 
cmd[256];
    
cmd strtok(cmdtextidx);
    
    
// Public commands.
    
if(strcmp("/enter"cmdtrue) == 0// enter property
    
{
        if( 
lastPickup[playerid] != -|| properties[lastPickup[playerid]][eType] > ){
            new
                
id propPickups[lastPickup[playerid]],
                
Float:x,
                
Float:y,
                
Float:z;
            
GetPropertyEntranceidxy);
            if( 
IsPlayerInRangeOfPointplayerid3.0xy)){
                
PutPlayerInPropertyplayeridid );
                
SendClientMessageplayerid0x55AADDFF"* You have entered a property.. type /exit to leave" );
                return 
1;
            }
        }
        return 
1;
    }
    else if(
strcmp("/exit"cmdtrue) == 0// exit property
    
{
        if( 
currentInt[playerid] > -&& GetPlayerInterior(playerid) == GetPropertyInteriorIdcurrentInt[playerid] )){
            new 
id currentInt[playerid];
            new 
Float:x;
            new    
Float:y;
            new    
Float:z;
            new    
Float:a;
            
// make sure they're near the exit before allowing them to exit.
            
GetPropertyExitidxy);
            if(!
IsPlayerInRangeOfPoint(playerid,4.5,x,y,z)) {
                
SendClientMessage(playerid,0xDDAA55FF,"* You must be near the property exit to /exit");
                return 
1;
            }
            
GetPropertyEntranceidxy);
            
SetPlayerPosplayeridxy);
            
SetPlayerFacingAngleplayerid);
            
SetPlayerInteriorplayerid);
            
SetPlayerVirtualWorldplayerid);
        }
        
currentInt[playerid] = -1;
        return 
1;
    } 
This is my /enter and /exit command. No warnings so I wanted to change them with "y" to enter/exit.
Reply
#2

they key Y is not supported by default, but u can add a plugin that detects the key (there is one, i forgot the name tho)
Reply
#3

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
they key Y is not supported by default, but u can add a plugin that detects the key (there is one, i forgot the name tho)
I just want it to enter/exit in properties by pressing y. If someone help me I gonna rep ya
Reply
#4

I have used that a while ago https://sampforum.blast.hk/showthread.php?tid=268671
its not pefect for your purpose but u can try
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
they key Y is not supported by default, but u can add a plugin that detects the key (there is one, i forgot the name tho)
It is since 0.3d, KEY_YES (by default in GTA:SA the key is Y), and i don't think there is such plugin.

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
I have used that a while ago https://sampforum.blast.hk/showthread.php?tid=268671
its not pefect for your purpose but u can try
That's for SERVER, not for player's game client.



You can use OnPlayerKeyStateChange and detect if key pressed is KEY_YES, also since you are not using /enter /exit, you need to change the if-condition code because you will be using the same key to enter and exit, which you would need to adjust from your code that i helped:
Код:
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(PRESSED(KEY_YES))
	{
		if(currentInt[playerid] > -1 && GetPlayerInterior(playerid) == GetPropertyInteriorId(currentInt[playerid]))
		{
			new id = currentInt[playerid];
			new Float:x, Float:y, Float:z, Float:a;

			// make sure they're near the exit before allowing them to exit.
			GetPropertyExit(id, x, y, z);
			if(IsPlayerInRangeOfPoint(playerid, 4.5, x, y, z))
			{
				a = GetPropertyEntrance(id, x, y, z);
				SetPlayerInterior(playerid, 0);
				SetPlayerPos(playerid, x, y, z);
				SetPlayerFacingAngle(playerid, a);
				SetPlayerVirtualWorld(playerid, 0);
				currentInt[playerid] = -1;
			}
			else
			{
				SendClientMessage(playerid, 0xDDAA55FF, "* You must be near the property exit to exit");
			}
		}
		else if(lastPickup[playerid] != -1 || properties[lastPickup[playerid]][eType] > 0)
		{
			new id = propPickups[lastPickup[playerid]];
			new Float:x, Float:y, Float:z;
			GetPropertyEntrance(id, x, y, z);
			if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
			{
				PutPlayerInProperty(playerid, id);
				SendClientMessage(playerid, 0x55AADDFF, "* You have entered a property.. Press ~k~~CONVERSATION_YES~ near exit to leave");
			}
		}
	}
	return 1;
}
Note: I think it's better to set the interior first then set the player pos.
This code is not tested yet, hope it helps.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)