Jump to content
Autentificarea cu Google și Facebook nu mai este disponibilă. ×

Question

Posted

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!

9 answers to this question

Recommended Posts

  • 0
Posted

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;
}

 

  • 0
Posted

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;
	}
}

 

  • 0
Posted (edited)

@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
  • 0
Posted (edited)

@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;
}

 

  • 0
Posted

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.

  • 0
Posted
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;

  • 0
Posted

@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;
}

 

  • 0
Posted

are dreptate @Ph0eniX

 

de ce utilizezi un string de 180 cand nu este cazul? ai 42 caractere in SCM + numele jucatorilor care cred ca este maxim 25 caractere deci 67 caractere.un string de 70 caractere era de ajuns,nu e nevoie de 180.

  • 0
Posted

Eu am copiat comanda lui, ma refeream ca paul a zis ca nu poti da 0 la un float.

Iar o variabila deja iti ocupa memorie, de ce sa o folosesti daca nu-si are rostul?

Cu tine phoenix nu am vorbit deloc.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.