SA-MP Forums Archive
Command doesn't work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command doesn't work (/showthread.php?tid=598490)



Command doesn't work - ZachKnoxx - 13.01.2016

Код:
CMD:taxitest(playerid, params[])
{
        Taxi_ShowCalls(playerid);
        return 1;
}
Код:
stock Taxi_ShowCalls(playerid)
{
    static
	    string[2048];

	string[0] = 0;

	foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) 
	{
	    format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i));
	}
	if (!strlen(string)) 
	{
	    SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept.");
	}
	else SendClientMessage(playerid, COLOR_LIGHTRED, string);
	return 1;
}
When I type /taxitest in-game, it comes up with SERVER: Unknown Command. Does anyone know why and what's wrong with my coding?


Re: Command doesn't work - lucamsx - 13.01.2016

maybe this? i'm not sure.
Код:
	foreach (new i : Player) 
	{
	    if(GetPVarInt(i, "TaxiRequest") == 1) //change 1 to whatever you're using in this PVar
	    {
	    	format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i));
            SendClientMessage(playerid, COLOR_LIGHTRED, string);
		}
	}



Re: Command doesn't work - Eth - 13.01.2016

static
string[2048];

that's a lot, don't you think? and why did you do static?
just do

new string[200]; is fair enough.


Re: Command doesn't work - ZachKnoxx - 13.01.2016

Still the same issue.


Re: Command doesn't work - -CaRRoT - 13.01.2016

Quote:
Originally Posted by ZachKnoxx
Посмотреть сообщение
Код:
CMD:taxitest(playerid, params[])
{
        Taxi_ShowCalls(playerid);
        return 1;
}
Код:
stock Taxi_ShowCalls(playerid)
{
    static
	    string[2048];

	string[0] = 0;

	foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) 
	{
	    format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i));
	}
	if (!strlen(string)) 
	{
	    SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept.");
	}
	else SendClientMessage(playerid, COLOR_LIGHTRED, string);
	return 1;
}
When I type /taxitest in-game, it comes up with SERVER: Unknown Command. Does anyone know why and what's wrong with my coding?
Is that the only ZCMD command you're using? I doubt this would solve it but I remember having the same issue and I had to switch from using CMD: to COMMAND:, give it a shot.


Re: Command doesn't work - Crayder - 13.01.2016

Quote:
Originally Posted by Eth
Посмотреть сообщение
static
string[2048];

that's a lot, don't you think? and why did you do static?
just do

new string[200]; is fair enough.
Yes, that is very large and should be made smaller. Yes it is static and it CAN BE STATIC. It's static to that function, so it makes sense if you know what it means. Plus you're already trying to clear it ("[0] = 0") so it's fine.

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
Is that the only ZCMD command you're using? I doubt this would solve it but I remember having the same issue and I had to switch from using CMD: to COMMAND:, give it a shot.
"COMMAND" and "CMD" are synonymous in ZCMD. In fact, they are just both just predefined macros to the same shit. So no that's not the problem.

@OP: Put some 'print's all over (EVERYWHERE). See where they get printed and where they don't.


Re: Command doesn't work - ZachKnoxx - 13.01.2016

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Yes, that is very large and should be made smaller. Yes it is static and it CAN BE STATIC. It's static to that function, so it makes sense if you know what it means. Plus you're already trying to clear it ("[0] = 0") so it's fine.

"COMMAND" and "CMD" are synonymous in ZCMD. In fact, they are just both just predefined macros to the same shit. So no that's not the problem.

@OP: Put some 'print's all over (EVERYWHERE). See where they get printed and where they don't.
Alright. As soon as I added a print to it, it gave me an error. Same coding and everything, just an extra print.

Код:
stock Taxi_ShowCalls(playerid)
{
    static
	    string[2048];

	string[0] = 0;

	foreach (new i : Player) if (GetPVarInt(i, "TaxiRequest")) print("1");
	{
	    format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i)); // this line gets an error
	}
	if (!strlen(string)) 
	{
	    SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept.");
	}
	else SendClientMessage(playerid, COLOR_LIGHTRED, string);
	return 1;
}
Код:
Line(8459) : error 017: undefined symbol "i"



Re: Command doesn't work - Crayder - 13.01.2016

Well obviously, you can't put a print there. It's outside of the block so by the time the block is being executed 'i' is no longer defined.

pawn Код:
stock Taxi_ShowCalls(playerid)
{
    static
        string[2048];

    string[0] = 0;
    printf("string = %s", string);

    foreach (new i : Player) {
        if (GetPVarInt(i, "TaxiRequest"))
        {
            format(string, sizeof(string), "%s%d: %s (%s)", string, i, GetPlayerNameEx(i, ENameType_RPName_NoMask), GetPlayerLocation(i));
            print("appending");
        }
    }
    if (!strlen(string))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "There are no taxi calls to accept.");
        print("if")
    }
    else SendClientMessage(playerid, COLOR_LIGHTRED, string), print("else");
    print("end");
    return 1;
}



Re: Command doesn't work - -CaRRoT - 13.01.2016

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Yes, that is very large and should be made smaller. Yes it is static and it CAN BE STATIC. It's static to that function, so it makes sense if you know what it means. Plus you're already trying to clear it ("[0] = 0") so it's fine.

"COMMAND" and "CMD" are synonymous in ZCMD. In fact, they are just both just predefined macros to the same shit. So no that's not the problem.

@OP: Put some 'print's all over (EVERYWHERE). See where they get printed and where they don't.
Doesn't mean that I didn't have that issue and renaming it helped.