CMD:opengateandattach(playerid)
{
//MoveObect...
//AttachObjectToObject...
SendClientMessage(playerid,-1,"You opened the gate!");
// Don't forget a way to close the gate, and a check to know if the gate is open will be also good ;)
return 1;
}
This is simple! All you have to know is basics about creating some commands!
https://sampforum.blast.hk/showthread.php?tid=280476 To attach an objecto into another object use this: https://sampwiki.blast.hk/wiki/AttachObjectToObject To 'open' gates, just move them using this: https://sampwiki.blast.hk/wiki/MoveObject To 'close' gates, just move them back to the original position. Try, and post your doubts here The final result should be like this: pawn Код:
|
CMD:bay1o(playerid, params[]) { AttachObjectToObject(1238, 1262, -269.2437, 1187.3073, 23.1069, 0.0000, 0.0000, 0.0000, 1); SendClientMessage(playerid, COLOR_GREEN,"Bay 1 is open"); MovePlayerObject(playerid, Gate1[playerid], -254.7196, 1209.9005, 16.3944, 1); return 1; }
Sure this is how I tried to make it:
Код:
CMD:bay1o(playerid, params[]) { AttachObjectToObject(1238, 1262, -269.2437, 1187.3073, 23.1069, 0.0000, 0.0000, 0.0000, 1); SendClientMessage(playerid, COLOR_GREEN,"Bay 1 is open"); MovePlayerObject(playerid, Gate1[playerid], -254.7196, 1209.9005, 16.3944, 1); return 1; } |
AttachObjectToObject(1238, 1262, -269.2437, 1187.3073, 23.1069, 0.0000, 0.0000, 0.0000, 1);
This
pawn Код:
|
CMD:bay1o(playerid, params[]) { Gate1[playerid] = CreateObject(1238, -269.2469, 1187.2875, 23.1069, 0.0000, 0.0000, 0.0000); AttachObjectToObject(1238, 1262, -269.2437, 1187.3073, 23.1069, 0.0000, 0.0000, 0.0000, 1); SendClientMessage(playerid, COLOR_GREEN,"Bay 1 is open"); MovePlayerObject(playerid, Gate1[playerid], -254.7196, 1209.9005, 16.3944, 1); return 1; }
Okay now I made the object to appear, this is how all the script looks like, but now the gate wont open:
Код:
CMD:bay1o(playerid, params[]) { Gate1[playerid] = CreateObject(1238, -269.2469, 1187.2875, 23.1069, 0.0000, 0.0000, 0.0000); AttachObjectToObject(1238, 1262, -269.2437, 1187.3073, 23.1069, 0.0000, 0.0000, 0.0000, 1); SendClientMessage(playerid, COLOR_GREEN,"Bay 1 is open"); MovePlayerObject(playerid, Gate1[playerid], -254.7196, 1209.9005, 16.3944, 1); return 1; } |
CMD:bay1o(playerid, params[])
{
Gate1[playerid] = CreateObject(bla);
ObjectToAttached[playerid] = CreateObject(bla);
AttachObjectToObject(Gate1[playerid], ObjectToAttached[playerid], blablaa);
and so on
}
Not the modelid of your object.