Jump to content

[Tutorial] Atac aerian cu rachete asupra jucatorilor


ARTIST

Recommended Posts

jfz8ehuxct4sg3m1cw7y.png

 

Va prezint un sistem de atac aerian cu rachete asupra unui jucator.

Acest sistem a stat de mai bine 3 ani si ceva in calculatorul meu si anume astazi am decis sa il public.

 

 

 

et1zga51pf1zr3j4.png

 

Atunci cand un jucator (in cazul meu un Admin. La decizia dumneavoastra acesta poate fi un Leader, membru NG, etc.) va introduce comanda /flyattack [id] , atunci asupra jucatorului respectiv (cu id-ul introdus) vor fi lansate 3 rachete, ce vor exploda odata ce vor intra in contact cu acesta, eventual il vor distruge (omora).

In asa fel, cat sistemul de lansare va fi activat si in desfasurare, nu va fi posibil de folosit pe un alt jucator, pana rachetele lansate mai devreme, nu vor atinge tinta indicata.

 

 

 

epzse7mcrbjs1h5wciszk5dipr7y.png

 

Anuntam variabilele globale:

 

new pRocket[3],
Float:X,
Float:Y,
Float:Z,
Aimer INVALID_PLAYER_ID,
Timer[MAX_PLAYERS],
bool:Attack false;

 

 

In public OnPlayerCommandText vom adauga urmatoarele. Nu voi sta sa explic codul de mai jos deoarece acolo si asa totul este foarte usor de inteles:

 

new cmd[128],idx,tmp[128];
    
cmd strtok(cmdtextidx);
    if(
strcmp(cmd,"/flyattack",true) == 0)
    {
        
tmp strtok(cmdtext,idx);
        if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"Nu aveti acces la aceasta comanda!");
        if(!
strlen(tmp)) return SendClientMessage(playerid,0xFFFFFFFF,"Folositi /flyattack [ID jucator]");
        new 
pid strval(tmp);
        if(!
IsPlayerConnected(pid)) return SendClientMessage(playerid,0xFFFFFFFF,"> Jucatorul nu este conectat!");
        if(
GetPlayerInterior(pid) != 0) return SendClientMessage(playerid,0xFFFFFFFF,"> Jucatorul se afla intr-un interior si nu poate fi depistat!");
        if(
Attack) return SendClientMessage(playerid,0xF60000FF,"> Atacul cu rachete este deja activat!");
        
pRocket[0] = INVALID_OBJECT_ID;
        
pRocket[1] = INVALID_OBJECT_ID;
        
pRocket[2] = INVALID_OBJECT_ID;
        
Attack true;
        
Aimer playerid;
        
GetPlayerPos(pid,X,Y,Z);
        
pRocket[0] = CreateObject(354,X,Y,Z+500.0,0.0,0.0,0.0);
        
pRocket[1] = CreateObject(354,X,Y,Z+510.0,0.0,0.0,0.0);
        
pRocket[2] = CreateObject(354,X,Y,Z+515.0,0.0,0.0,0.0);
        
MoveObject(pRocket[0],X,Y,Z-5,70.0);
        
MoveObject(pRocket[1],X,Y,Z-5,70.0);
        
MoveObject(pRocket[2],X,Y,Z-5,70.0);
        
Timer[pid] = SetTimerEx("ObjectUpdate",100,true,"dd",pid,pRocket[0]);
        new 
Name[32],string[128];
        
GetPlayerName(pid,Name,sizeof(Name));
        
format(string,sizeof(string),"> Atacul cu rachete asupra jucatorului %s a fost activat!",Name);
        
SendClientMessage(playerid,0xF60000AA,string);
        return 
1;
    }

 

 

Acum vom crea un public care vine de la timer si va exploda jucatorul:

 

(playerid,objectid);
public 
ObjectUpdate(playerid,objectid)
{
    if(!
Attack) return KillTimer(Timer[playerid]);
    new 
Float:oX[6];
    
GetObjectPos(objectid,oX[0],oX[1],oX[2]);
    
GetPlayerPos(playerid,oX[3],oX[4],oX[5]);
    if(
oX[2] < oX[5])
    {
    
DestroyObject(pRocket[0]);
    
DestroyObject(pRocket[1]);
    
DestroyObject(pRocket[2]);
    
CreateExplosion(X+RandomValue(-10,10),Y+RandomValue(-10,10),Z,6,10.0);
    
CreateExplosion(X+RandomValue(-10,10),Y+RandomValue(-10,10),Z,6,10.0);
    
CreateExplosion(X+RandomValue(-10,10),Y+RandomValue(-10,10),Z,6,10.0);
    
SendClientMessage(Aimer,-1,"> Rachetele lansate au atacat cu succes tinta!");
    
KillTimer(Timer[playerid]);
    
Attack false;
    }
    return 
1;
}
forward ObjectUpdate

 

 

In codul sistemului au mai ramas 2 functii pe care le vom adauga la sfarsitul modului:

 

stock strtok(const string[],&index,seperator=' ')
{
    new 
length strlen(string),offset index,result[64];
    while((
index length) && (string[index] != seperator) && ((index offset) < (sizeof(result) - 1)))
    {
    
result[index offset] = string[index];
    
index++;
    }
    
result[index offset] = EOS;
    if((
index length) && (string[index] == seperator))
    {
    
index++;
    }
    return 
result;

 

 

stock strtok(const string[],&index,seperator=' ')
{
    new 
length strlen(string),offset index,result[64];
    while((
index length) && (string[index] != seperator) && ((index offset) < (sizeof(result) - 1)))
    {
    
result[index offset] = string[index];
    
index++;
    }
    
result[index offset] = EOS;
    if((
index length) && (string[index] == seperator))
    {
    
index++;
    }
    return 
result;

 

 

Autorul sistemului: Gameyer (09.07.2011)

Autorul modificarilor: ARTIST

 

 

ep41yhufqpagka5wfoornw1wjfjie.png

Edited by ARTIST

ep41yhufqpagka5wfoornw1wjfjie.png

HTjr_G.png
12975.png
 
Link to comment
Share on other sites

  • 2 months later...

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.