KEY_SECONDARY_ATTACK and /enter - 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: KEY_SECONDARY_ATTACK and /enter (
/showthread.php?tid=481621)
KEY_SECONDARY_ATTACK and /enter -
mrxqware - 16.12.2013
Dear guys,
I tried to write a script to let people enter houses and businesses using /enter or the KEY_SECONDARY_ATTACK key. Buy I don't know how to get it to work.
Could someone help me please?
I've tried to use:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( newkeys == KEY_SECONDARY_ATTACK )
{
}
return 1;
}
But I don't know how to implement it.
http://pastebin.com/Euw8PmSK
Thank you,
Michael
Re: KEY_SECONDARY_ATTACK and /enter -
dominik523 - 16.12.2013
You would do something like this:
pawn Код:
for(new idx=1; idx<MAX_BIZ; idx++)
{
if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])) // these are the coordinates from your business enum
{
// set player position to the interior of the business and the rest
}
}
So this code searches for the nearest business that the player is from.
Re: KEY_SECONDARY_ATTACK and /enter - Patrick - 16.12.2013
Quote:
Originally Posted by dominik523
You would do something like this:
pawn Код:
for(new idx=1; idx<MAX_BIZ; idx++) { if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])) // these are the coordinates from your business enum { // set player position to the interior of the business and the rest } }
So this code searches for the nearest business that the player is from.
|
There is another trick, you don't need to re-code it :P
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( newkeys & KEY_SECONDARY_ATTACK )
return OnPlayerCommandText(playerid, "/enter");
return true;
}
Re: KEY_SECONDARY_ATTACK and /enter -
dominik523 - 16.12.2013
@pds2k12 very clever I must say. I would never think of something like that. Good work!
Re: KEY_SECONDARY_ATTACK and /enter -
mrxqware - 17.12.2013
Yahoooo!!! It's working! Thank you guys.
Re: KEY_SECONDARY_ATTACK and /enter -
mrxqware - 17.12.2013
Is there a way to use the same KEY_SECONDARY_ATTACK to exit?
I've tried this, but it does not work. I can enter. But not exit using the same key.
Quote:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( newkeys & KEY_SECONDARY_ATTACK ){
return OnPlayerCommandText(playerid, "/enter");
// return true;
}
if( newkeys & KEY_SECONDARY_ATTACK ){
return OnPlayerCommandText(playerid, "/exit");
// return true;
}
|