Alright, Before i was trying to make two objects controllable with bind keys, Here you go you might get an example from this i hope.
pawn Код:
#include <a_samp>
#include <zcmd>
new FlyDs[MAX_PLAYERS];
new FlyPs[MAX_PLAYERS];
new obj1;
new obj2;
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" .. ..");
print("--------------------------------------\n");
return 1;
}
#endif
public OnGameModeInit()
{
obj1 = CreateObject(16771,-1175.88977051,-302.76074219,23.08684540,0.00000000,0.00000000,332.71545410); //Des_Savhangr
obj2 = CreateObject(8493,-992.20349121,10.18408966,17.33088875,0.00000000,0.00000000,0.00000000); //PirateShip
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, 0x33AA33AA, "Please type /Flyds if you want to fly Des_savhangr.");
SendClientMessage(playerid, 0x33AA33AA, "Please type /Flyps if you want to fly PirateShip.");
FlyDs[playerid] = 0;
FlyPs[playerid] = 0;
return 1;
}
//Cmds
COMMAND:flyds(playerid, params[])
{
SendClientMessage(playerid, 0x33AA33AA, "You're now alloweded to fly the Des_savhangr, Please type /Flyingkeys to see list of keys to move.");
SendClientMessage(playerid, 0x33AA33AA, "You can now park Planes, Vehicles etc inside the Des_savhangr.");
FlyDs[playerid] = 1;
SetPlayerFacingAngle( playerid, 270 );
return 1;
}
COMMAND:offflyds(playerid, params[])
{
SendClientMessage(playerid, 0x33AA33AA, "You're now not disalloweded to fly the Des_savhangr , Please type /Fly again if you want to fly Des_savhangr.");
FlyDs[playerid] = 0;
return 1;
}
COMMAND:flyps(playerid, params[])
{
SendClientMessage(playerid, 0x33AA33AA, "You're now alloweded to fly the PirateShip, Please type /Flyingkeys to see list of keys to move.");
FlyPs[playerid] = 1;
SetPlayerFacingAngle( playerid, 270 );
return 1;
}
COMMAND:offflyps(playerid, params[])
{
SendClientMessage(playerid, 0x33AA33AA, "You're now not disalloweded to fly the PirateShip , Please type /Flyps again if you want to fly PirateShip.");
FlyPs[playerid] = 0;
return 1;
}
COMMAND:flyingkeys(playerid, params[])
{
SendClientMessage(playerid, 0x33AA33AA, "Move Up: ( SHIFT ) .. Move Down: ( Left Mouse Button )");
SendClientMessage(playerid, 0x33AA33AA, "Move Left: ( Alphabet C ) .. Move Right: ( Mouse Middle Circle Button.)");
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
//Des Savhangr
//.. Key Up ..
if(FlyDs[playerid] == 1){
if(PRESSED(KEY_JUMP)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y, z + 10, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: Des_savhangr moved 10 meters Up!");
}
}
// .. Key Down ..
if(FlyDs[playerid] == 1){
if(PRESSED(KEY_FIRE)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y, z - 10, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: Des_savhangr moved 10 meters Down!");
}
}
//.. Key Left ..
if(FlyDs[playerid] == 1){
if(PRESSED(KEY_CROUCH)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y + 10, z, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: Des_savhangr moved 10 meters Left!");
}
}
//.. Key Right ..
if(FlyDs[playerid] == 1){
if(PRESSED(KEY_LOOK_BEHIND)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y - 10, z, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: Des_savhangr moved 10 meters Right!");
}
}
//PirateShip
//.. Key Up ..
if(FlyPs[playerid] == 1){
if(PRESSED(KEY_JUMP)) {
new Float:x,Float:y,Float:z;
MoveObject(obj2, x, y, z + 10, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: PirateShip moved 10 meters Up!");
}
}
//.. Key Down ..
if(FlyPs[playerid] == 1){
if(PRESSED(KEY_FIRE)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y, z - 10, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: PirateShip moved 10 meters Down!");
}
}
//.. Key Left ..
if(FlyPs[playerid] == 1){
if(PRESSED(KEY_CROUCH)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y + 10, z, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: PirateShip moved 10 meters Left!");
}
}
//.. Key Right ..
if(FlyPs[playerid] == 1){
if(PRESSED(KEY_LOOK_BEHIND)) {
new Float:x,Float:y,Float:z;
MoveObject(obj1, x, y - 10, z, 4.00);
SendClientMessage(playerid, 0x33AA33AA, "Object: PirateShip moved 10 meters Right!");
}
}
return 1;
}