Jump to content
  • 0

/gotocp comanda


Davidoff7776

Question

Salut! Ma mai puteti ajuta cu o comanda?

 

CMD:gotocp(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] < 1) return 1;
    if(InGame[playerid] == 1) return SCM(playerid, COLOR_LGREEN, "Nu poti folosi aceasta comanda deoarece esti in arena! Foloseste comanda /leavearena pentru a iesi.");
    SetPlayerPosEx(playerid,CheckpointPos[playerid][0], CheckpointPos[playerid][1], CheckpointPos[playerid][2]);
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerInterior(playerid, 0);
    new string[180];
    format(string, sizeof(string), "AdmCmd: %s s-a teleportat la checkpoint.", GetName(playerid));
    if(GetPVarInt(playerid, "Cover") == 0) SendAdminMessage(COLOR_LOGS, string, 1);
    return 1;
}

 

Aceasta comanda teleporteaza un admin la un checkpoint dar as dori daca va pricepeti sa-i mai adaugati un SendClientMessage atunci cand nu are niciun checkpoint pe mapa. De exemplu

SendClientMessage(playerid, COLOR_RED, "Nu ai niciun checkpoint pe mapa"

Multumesc anticipat!

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Defapt e mai bine așa... :

CMD:gotocp(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return 1;
    if(InGame[playerid] == 1)
		return SCM(playerid, COLOR_LGREEN, "Nu poti folosi aceasta comanda deoarece esti in arena! Foloseste comanda /leavearena pentru a iesi.");

    new string[60];
    if(CheckpointPos[playerid][0] == 0.0)
        return SendClientMessage(playerid,COLOR_RED, "Nu ai nici-un checkpoint pe mapa");
        
	SetPlayerPosEx(playerid,CheckpointPos[playerid][0], CheckpointPos[playerid][1], CheckpointPos[playerid][2]);
    SetPlayerVirtualWorld(playerid, 0);
    SetPlayerInterior(playerid, 0);
    format(string, sizeof(string), "AdmCmd: %s s-a teleportat la checkpoint.", GetName(playerid));
    if(GetPVarInt(playerid, "Cover") == 0) SendAdminMessage(COLOR_LOGS, string, 1);
    CheckpointPos[playerid][0] = 0.0;
    return 1;
}

 

  • Upvote 1
public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

Link to comment
Share on other sites

  • 0

Imi asumez ca resetezi CheckpointPos si ii dai valoarea 0.

CMD:gotocp(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] < 1) 																		return 1;
    if(InGame[playerid] == 1) 																					return SCM(playerid, COLOR_LGREEN, "Nu poti folosi aceasta comanda deoarece esti in arena! Foloseste comanda /leavearena pentru a iesi.");
    if(CheckpointPos[playerid][0] == 0 && CheckpointPos[playerid][1] == 0 && CheckpointPos[playerid][2] == 0) 	return SCM(playerid, COLOR_RED, "Nu ai niciun checkpoint pe mapa");
    else
    {
	    SetPlayerPosEx(playerid, CheckpointPos[playerid][0], CheckpointPos[playerid][1], CheckpointPos[playerid][2]);
	    SetPlayerVirtualWorld(playerid, 0);		SetPlayerInterior(playerid, 0);
	    new string[180];
	    format(string, sizeof(string), "AdmCmd: %s s-a teleportat la checkpoint.", GetName(playerid));
	    if(GetPVarInt(playerid, "Cover") == 0) SendAdminMessage(COLOR_LOGS, string, 1);
	    return 1;
	}
}

 

Link to comment
Share on other sites

  • 0

@cristiviteza ,in primul rand checkpointpos este un float,nu un numar.

in al doilea rand,cand setezi CheckPointPos unui playerid,ii setezi si alta variabila pe 0/1 care sa verifice daca are o destinatie setata?Daca nu,poti face cum a zis Ph0eniX.

Iti recomand sa folosesti variabile normale in locul PVar-urilor, deoarece variabilele normale sunt mult mai rapide decat pvar-urile.

@Ph0eniX , de ce ai seta coordonata X la 0 prin 

CheckpointPos[playerid][0] = 0.0;

?

Edited by PauLL
  • Upvote 1
Link to comment
Share on other sites

  • 0

@PauLL

Pentru a verifica dacă are sau nu checkpoint , dacă prima dată îi apare ca n-are cp , atunci e ok dar a 2-a oară cand folosește comanda , îi nu-i mai apare ca n-are CP ci îl teleportează direct. Pentru asta este acea funcție. Nu știu exact cum are comenzile dar dacă are ceva de genu

new Float:TestPos[3];

CMD:setcp(..)
{
	....
	TestPos[0] = ....;
	TestPos[1] = ....;
	TestPos[2] = ....;
	SetPlayerCP....
	....
}

CMD:gotocp(..)
{
	if(TestPos[0] == 0.0) <= aici nu-l lasă să treacă , deoarece nu a fost folosită comanda setcp
	Aici continuă dacă TestPos nu este 0.0 și îi setează poziția sau ce are el nevoie. 
	După care , setăm poziția înapoi la 0.0 pentru ce are el nevoie , adică sa îi spună ca nu are CP 
	TestPos[0] = 0.0;
}

Este un exemplu ce am dat mai sus , nu trebuie să fie exact cum am spus eu acuma dar este ceva asemănător. Sper că ai înțeles.

Edited by Ph0eniX
  • Upvote 1
public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

Link to comment
Share on other sites

  • 0

0 este si numar real btw, poti sa dai unui float si valoarea 0(cel putin la mine in gamemode, pot sa ii dau si 0). Si de ce sa folosesti doua variabile cand astea 3 sunt de ajuns? Chestie de optimizare. Poti folosi doar coordonatele si cand au valoarea default(0, 0, 0) poti considera ca nu are niciun checkpoint.

Link to comment
Share on other sites

  • 0
Acum 19 minute, Ph0eniX a spus:

@PauLL

Pentru a verifica dacă are sau nu checkpoint , dacă prima dată îi apare ca n-are cp , atunci e ok dar a 2-a oară cand folosește comanda , îi nu-i mai apare ca n-are CP ci îl teleportează direct. Pentru asta este acea funcție. Nu știu exact cum are comenzile dar dacă are ceva de genu


new Float:TestPos[3];

CMD:setcp(..)
{
	....
	TestPos[0] = ....;
	TestPos[1] = ....;
	TestPos[2] = ....;
	SetPlayerCP....
	....
}

CMD:gotocp(..)
{
	if(TestPos[0] == 0.0) <= aici nu-l lasă să treacă , deoarece nu a fost folosită comanda setcp
	Aici continuă dacă TestPos nu este 0.0 și îi setează poziția sau ce are el nevoie. 
	După care , setăm poziția înapoi la 0.0 pentru ce are el nevoie , adică sa îi spună ca nu are CP 
	TestPos[0] = 0.0;
}

Este un exemplu ce am dat mai sus , nu trebuie să fie exact cum am spus eu acuma dar este ceva asemănător. Sper că ai înțeles.

Nu mai e nevoie sa fac si chestia asta ca merge si fara , insa intr-adevar este nevoie si de

CheckpointPos[playerid][0] = 0.0;

Link to comment
Share on other sites

  • 0

@cristiviteza eu nu înțeleg care e problema dacă este 0.0 sau 0 , este ACELAȘI LUCRU dar în fine nu am eu chef să stau la vorbă pe tema asta , fiecare folosește ce vrea. Și la așa ceva , nu se optimizează GM-ul. Optimizarea GM-ului se face în alte moduri , de exemplu...

1 oră în urmă, cristiviteza a spus:

Imi asumez ca resetezi CheckpointPos si ii dai valoarea 0.


CMD:gotocp(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] < 1) 																		return 1;
    if(InGame[playerid] == 1) 																					return SCM(playerid, COLOR_LGREEN, "Nu poti folosi aceasta comanda deoarece esti in arena! Foloseste comanda /leavearena pentru a iesi.");
    if(CheckpointPos[playerid][0] == 0 && CheckpointPos[playerid][1] == 0 && CheckpointPos[playerid][2] == 0) 	return SCM(playerid, COLOR_RED, "Nu ai niciun checkpoint pe mapa");
    else
    {
	    SetPlayerPosEx(playerid, CheckpointPos[playerid][0], CheckpointPos[playerid][1], CheckpointPos[playerid][2]);
	    SetPlayerVirtualWorld(playerid, 0);		SetPlayerInterior(playerid, 0);
	    new string[180];
	    format(string, sizeof(string), "AdmCmd: %s s-a teleportat la checkpoint.", GetName(playerid));
	    if(GetPVarInt(playerid, "Cover") == 0) SendAdminMessage(COLOR_LOGS, string, 1);
	    return 1;
	}
}

 

new string[180]; 

Unde este optimizarea despre care vorbești? În fine...nu mă mai complic și nici nu mă iau in vorbă cu voi. Baftă.

public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

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
Answer this question...

×   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.