Jump to content

SetObjectRot cu Exemplu


monster010

Recommended Posts

M-am hotarat sa fac acest tutorial din doua motive :

1. M-au intrebat multi "cum sa fac o comanda cu SetObjectRot".

2. Vreu sa va ajut.

Acuma ca stiti motivele se ne apucam de lucru.

O sa va zic pasii care trebuie fie facuti pana la comanda :

Pasul 1. Sa intram in MTA ( cel care il aveti voi ) creem un obiect (ex: gate , bariera , etc.) cand am terminat de facut dam save.

Pasul 2. Intram pe un site unde sa convertam pentru PAWNO.

Pasul 3. Am facut convertorul....o sa ne apara ceva de genu  CreateObject([iD-ul obiectului],[Coordonatele x,y,z], [RotX, RotY, RotZ]); cea ce ne intereseaza sunt rotatiile X,Y,Z

Pasul 4. Sa denumim obiectul : new objectPasul

Pasul 5. Trecem crearea obiectului la public OnGameModeInit() , va fi asa object =  CreateObject([iD-ul obiectului],[Coordonatele x,y,z], [RotX, RotY, RotZ ].( exemplu :  CreateObject([iD-ul obiectului],[Coordonatele x,y,z], 0.0000, 0.0000, 60.5471);

Acuma am sa va arat cum sa faceti comanda:

la public OnPlayerCommandText(playerid, cmdtext[]) scrie comanda :

    if(!strcmp(cmdtext, "/comanda", true))
    {
    if(PlayerInfo[playerid][pLeader] == [ID-ul factiunii] || PlayerInfo[playerid][pMember] == [ID-ul factiunii]// Daca vrem sa facem o comanda numai pentru o anumita factiune
    {
[b]	SetObjectRot([obiectul numit],rotX,rotY,rotZ);[/b]
	}
    else return SendClientMessage(playerid, COLOR_YELLOW,"Tu nu esti in [ce factiune doriti].");
    return 1;
}

Daca vreti sa faceti ca se inchida automat faceti urmatorii pasi :

1-La forward , scrieti forward GateClose();[sau cum vreti voi]

2-Jos de tot scrieti

public GateClose()

{

      return 1;

}

Un exemplu

public GateClose()

{

  SetObjectRot([obiectul numit], rotX,rotY,rotZ); sau

  MoveObject([obiectul numit],x,y,z,[timpul de miscare]);

      return 1;

}

PS : Nu iutati sa adugati la comanda SetTimer

Link to comment
Share on other sites

  • 1 month later...

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys==KEY_FIRE)
Exemplu :
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys==KEY_FIRE)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(10, playerid,x,y,z) || PlayerToPoint(10, playerid,x,y,z))
{
    MoveObject(obiectul, x, y, z, [sec de miscare];
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Proba.");
    SetTimer("obiectul",3500, false);
    return 1;
}
}
}
}

Link to comment
Share on other sites

  • 1 month later...

Am adaugat in GM urmatoarele linii:

new houseb;
forward housebClose();
houseb = CreateObject(968,1245.475,2579.409,10.655,0.0,-91.100,0.0);
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    if(!strcmp(cmdtext, "/housebarrier", true))
    {
    if(PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pLeader] == 6)
    {
      SetObjectRot(houseb, 0.0, 0.859, 0.0);
   	  SendClientMessage(playerid, COLOR_RED, "Bariera se va inchide in 3 secunde !");
      SetTimer("housebclose", 3000, false);
      return 1;
    }
    else
    {
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "Accesul Interzis !");
	}
	return 0;
    }
public housebClose()
{
	SetObjectRot(houseb,0.0,-91.100,0.0);
	return 1;
}

Toate bune si frumoase , nici o eroare sau warn la Compile , dar cand intru in joc , dau /housebarrier , se deschide , imi afiseaza mesajul dar nu se mai inchide la loc cum ar fi trebuit.Stie cineva ce trebuie sa mai adaug sau sa modific ?

Multumesc :)

Link to comment
Share on other sites

new houseb;

forward housebClose();

houseb = CreateObject(968,1245.475,2579.409,10.655,0.0,-91.100,0.0);

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
   if(!strcmp(cmdtext, "/housebarrier", true))
   {
       if(PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pLeader] == 6)
       {
           SetObjectRot(houseb, 0.0, 0.859, 0.0);
     SendClientMessage(playerid, COLOR_RED, "Bariera se va inchide in 3 secunde !");
           SetTimer("housebclose", 3000, 1);
           return 1;
       }
       else
       {
           SendClientMessage(playerid, COLOR_LIGHTBLUE, "Accesul Interzis !");
       }
       return 0;
   }

public housebclose()
{
   SetObjectRot(houseb,0.0,-91.100,0.0);
   return 1;
}

logo.png

ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

Link to comment
Share on other sites

Dar ce e schimbat acolo? Mi se par la fel . Am incercat si cum ai spus tu dar odata ce bariera s-a deschis , asa ramane  ??? Am incercat ambele variante.

Am dat edit. Incearca iar cum ti-am facut acum.

logo.png

ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

Link to comment
Share on other sites

Da , Am gasit , Mersi frumos again :)

EDIT :

=-" post="23214" timestamp="1261344110"]

new houseb;

forward housebClose();

houseb = CreateObject(968,1245.475,2579.409,10.655,0.0,-91.100,0.0);

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    if(!strcmp(cmdtext, "/housebarrier", true))
    {
        if(PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pLeader] == 6)
        {
            SetObjectRot(houseb, 0.0, 0.859, 0.0);
   	    SendClientMessage(playerid, COLOR_RED, "Bariera se va inchide in 3 secunde !");
            SetTimer("housebclose", 3000, 1);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "Accesul Interzis !");
        }
        return 0;
    }

public housebclose()
{
    SetObjectRot(houseb,0.0,-91.100,0.0);
    return 1;
}

Dupa ce execut comanda /housebarrier , Primele 2 dati se deschide si inchide cum trebuie dar apoi se inchide intr`o fractiune de secunda , se poate face ceva sau e bug de la SA:MP ?

Link to comment
Share on other sites

  • 2 weeks later...
Guest Razvan95

Am incercat sa il fac,si da eroare la linia 49 unde scrie

if (PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11)

si eroarea

C:\Users\Razvan\Desktop\salam.pwn(49) : error 017: undefined symbol "PlayerInfo"

C:\Users\Razvan\Desktop\salam.pwn(49) : warning 215: expression has no effect

C:\Users\Razvan\Desktop\salam.pwn(49) : error 001: expected token: ";", but found "]"

C:\Users\Razvan\Desktop\salam.pwn(49) : error 029: invalid expression, assumed zero

C:\Users\Razvan\Desktop\salam.pwn(49) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

4 Errors.

Link to comment
Share on other sites

  • 1 month later...

merg cu playeru ( meu ) unde vreau sa o bag dau /save si din savedposition trec coordonatele de acolo?

Da. In savedposition o sa gasesti un rand gen:

AddPlayerClass(ID, X, Y, Z, restu deja nu te mai intereseaza);

Iei doar X, Y si Z. (Fii atent la virgulele alea ca sa stii care e coordonata X, Y sau Z.)

logo.png

ATENTIE!!! Nu imi trimiteti mesaje private care au legatura cu scriptingul. NU mai scriptez.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.