Jump to content

[REZOLVAT] [Problema] Nu merge libraria YSI


qRuby.
 Share

Recommended Posts

  • Username : qRuby
  • Problema întâlnită: nu merge libraria YSI
  • Detalii despre problemă: -.
  • Ce ai încercat să faci înainte să postezi?: am incercat sa schimb libraria YSI cu alta dar tot asa face.
  • Cod sursa (recomandat pastebin.com) : 
    #include <a_samp>
    #include <YSI\y_iterate>
    #include <YSI\y_commands>
    
    new Iterator: Admin<MAX_PLAYERS>;
    
    YCMD:gotoxyz(playerid, params[], help) {
        new string[128], interior;
        new Float:x, Float:y, Float:z;
        if(sscanf(params, "fffi", x, y, z, interior)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: /gotoxyz <x> <y> <z> <interior>");
        SetPlayerPos(playerid, x, y, z);
        format(string, 128, "Te-ai teleportat la coordonatele x = %f, y = %f, z = %f, interiorul %d.",x,y,z,interior);
        SendClientMessage(playerid, COLOR_YELLOW2, string);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerInterior(playerid, interior);
        return 1;
    }
    
    YCMD:admins(playerid, params[], help) {
        new string[128];
        foreach(new i: Admin) {
            if(PlayerInfo[i][pAdmin] > 0) {
                format(string, 128, "%s - admin level %d", GetName(playerid), PlayerInfo[i][pAdmin]);
    			SendClientMessage(playerid, 0xFFFFFFFF, string);
            }
        }
        return 1;
    }
    
    YCMD:rac(playerid, params[], help) {
        SendClientMessage(playerid, COLOR_GREY, "Aceasta comanda a fost dezactivata deoarece toate vehiculele nefolosite se respawneaza automat in fiecare ora.");
        return 1;
    }
    
    public OnPlayerConnect(playerid)
    {
    	if(PlayerInfo[playerid][pAdmin] > 0) {
    		Iter_Add(Admin, playerid);
    		printf("adaug admin in grupa");
    	}	
    	return 1;
    }
    
    public OnPlayerDisconnect(playerid)
    {
    	if(PlayerInfo[playerid][pAdmin] > 0) {
    		Iter_Remove(Admin, playerid);
    		printf("scot admin din grupa");
    	}	
    	return 1;
    }

     

  • Alte detalii : dati-mi si mie lib YSI

XNgeArL.png

GKmys99.png?1

Link to comment
Share on other sites

Chiar acum, Leonard a spus:

Si care-i problema mai exact?

pai, intru pe server, scriu /rac sau /admins si nu merge, imi da server: unknown command.

la fel si la iteratori, intru pe server ca admin, nu ma adauga in lista de admini *Iter_Add(Admin, playerid)*

XNgeArL.png

GKmys99.png?1

Link to comment
Share on other sites

  • Administrator

pt y_commands trebuie sa modifici OnPlayerCommandPerformed

OnPlayerCommandPerformed

 

Acum este:

e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)

 

Exemplu:

public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	if(success == COMMAND_UNDEFINED)
	{
		SendClientMessage(playerid, -1, "Aceasta comanda nu exista.");
		return COMMAND_OK;
	}
	
	return COMMAND_OK;
}

 

Lista cu errorile:

enum e_COMMAND_ERRORS
{
    // The majority of these are even - odd numbers return "1" not "0".
    COMMAND_ZERO_RET      = 0 , // The command returned 0.
    COMMAND_OK            = 1 , // Called corectly.
    COMMAND_UNDEFINED     = 2 , // Command doesn't exist.
    COMMAND_DENIED        = 3 , // Can't use the command.
    COMMAND_HIDDEN        = 4 , // Can't use the command don't let them know it exists.
    COMMAND_NO_PLAYER     = 6 , // Used by a player who shouldn't exist.
    COMMAND_DISABLED      = 7 , // All commands are disabled for this player.
    COMMAND_BAD_PREFIX    = 8 , // Used "/" instead of "#", or something similar.
    COMMAND_INVALID_INPUT = 10, // Didn't type "/something".
}

 

Iar la Iteratori, ai inteles gresit cum se folosesc.

 

La comanda ta:

YCMD:admins(playerid, params[], help) {
    new string[128];
    foreach(new i: Admin) {
        if(PlayerInfo[i][pAdmin] > 0) {
            format(string, 128, "%s - admin level %d", GetName(playerid), PlayerInfo[i][pAdmin]);
			SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}

 

Functia GetName trebuie sa apeleze ID-ul adminului, nu al tau, iar acea verificare daca e admin, e inutila, pt ca in interator adaugi doar persoanele care au admin.

 

GetName(playerid) -> GetName(i)
    foreach(new i: Admin) {
        if(PlayerInfo[i][pAdmin] > 0) {
            format(string, 128, "%s - admin level %d", GetName(playerid), PlayerInfo[i][pAdmin]);
			SendClientMessage(playerid, 0xFFFFFFFF, string);
        }

->

foreach(new i: Admin) 
{
  format(string, 128, "%s - admin level %d", GetName(i), PlayerInfo[i][pAdmin]);
  SendClientMessage(playerid, 0xFFFFFFFF, string);
}

 

Link to comment
Share on other sites

Acum 3 minute, Leonard a spus:

pt y_commands trebuie sa modifici OnPlayerCommandPerformed


OnPlayerCommandPerformed

 

Acum este:


e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)

 

Exemplu:


public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	if(success == COMMAND_UNDEFINED)
	{
		SendClientMessage(playerid, -1, "Aceasta comanda nu exista.");
		return COMMAND_OK;
	}
	
	return COMMAND_OK;
}

 

Lista cu errorile:


enum e_COMMAND_ERRORS
{
    // The majority of these are even - odd numbers return "1" not "0".
    COMMAND_ZERO_RET      = 0 , // The command returned 0.
    COMMAND_OK            = 1 , // Called corectly.
    COMMAND_UNDEFINED     = 2 , // Command doesn't exist.
    COMMAND_DENIED        = 3 , // Can't use the command.
    COMMAND_HIDDEN        = 4 , // Can't use the command don't let them know it exists.
    COMMAND_NO_PLAYER     = 6 , // Used by a player who shouldn't exist.
    COMMAND_DISABLED      = 7 , // All commands are disabled for this player.
    COMMAND_BAD_PREFIX    = 8 , // Used "/" instead of "#", or something similar.
    COMMAND_INVALID_INPUT = 10, // Didn't type "/something".
}

 

Iar la Iteratori, ai inteles gresit cum se folosesc.

 

La comanda ta:


YCMD:admins(playerid, params[], help) {
    new string[128];
    foreach(new i: Admin) {
        if(PlayerInfo[i][pAdmin] > 0) {
            format(string, 128, "%s - admin level %d", GetName(playerid), PlayerInfo[i][pAdmin]);
			SendClientMessage(playerid, 0xFFFFFFFF, string);
        }
    }
    return 1;
}

 

Functia GetName trebuie sa apeleze ID-ul adminului, nu al tau, iar acea verificare daca e admin, e inutila, pt ca in interator adaugi doar persoanele care au admin.

 


GetName(playerid) -> GetName(i)

    foreach(new i: Admin) {
        if(PlayerInfo[i][pAdmin] > 0) {
            format(string, 128, "%s - admin level %d", GetName(playerid), PlayerInfo[i][pAdmin]);
			SendClientMessage(playerid, 0xFFFFFFFF, string);
        }

->

foreach(new i: Admin) 
{
  format(string, 128, "%s - admin level %d", GetName(i), PlayerInfo[i][pAdmin]);
  SendClientMessage(playerid, 0xFFFFFFFF, string);
}

 

mersi, la iteratori stiam de faza aia dar m-am incurcat eu acolo si am scris playerid in loc de i, asa se intampla cand scriptezi la 3 noaptea :))

XNgeArL.png

GKmys99.png?1

Link to comment
Share on other sites

  • Matt unlocked and locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...