SA-MP Forums Archive
Command bug - 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 bug (/showthread.php?tid=306031)



Command bug - HellviRus - 24.12.2011

Hello,
Thanks for viewing my post,
I'm making a gates system, this is my command :
Код:
	if(!strcmp(cmdtext, "/hg", true) || !strcmp(cmdtext, "/housegate", true))
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
		    SendClientMessage(playerid, COLOR_GREY, "Please enter the gate's password.");
		    return 1;
		}
		for(new s = 0; s <= sizeof(GateInfo); s++)
		{
			if(strcmp(tmp, GateInfo[s][gCode], true) == 0)
			{
			    if(GateInfo[s][gStatus] == 0)
				{
				    GateInfo[s][gStatus] = 1;
				    new Float:bridqs;
				    bridqs = GateInfo[s][Poz] - 5.0;
				    MoveDynamicObject(housegate[s], GateInfo[s][Pox], GateInfo[s][Poy], bridqs, 0.8);
					SendClientMessage(playerid, COLOR_WHITE, "Opened the gated.");
					return 1;
				}
				else
				{
				    GateInfo[s][gStatus] = 0;
				    MoveDynamicObject(housegate[s], GateInfo[s][Pox], GateInfo[s][Poy], GateInfo[s][Poz], 0.8);
        			SendClientMessage(playerid, COLOR_WHITE, "Closed the gated.");
					return 1;
				}
			}
		}
		return 1;
	}
But when I type it I receive an unknown command error.
Please help !


Re: Command bug - Norck - 24.12.2011

The problem is probably here:
pawn Код:
for(new s = 0; s <= sizeof(GateInfo); s++)
It should be like this:
pawn Код:
for(new s = 0; s < sizeof(GateInfo); s++)
Because max available array index is sizeof(GateInfo)-1


Re: Command bug - HellviRus - 25.12.2011

Ok I'll try it . Thanks


Re: Command bug - Buzzbomb - 25.12.2011

Did it work..


Re: Command bug - HellviRus - 25.12.2011

No ... The same error.


Re: Command bug - Buzzbomb - 25.12.2011

I might be wrong but i think you be better off using Dialogs if its gonna be a passworded gate..


Re: Command bug - HellviRus - 25.12.2011

Okey Buzzbomb, I'll try using Dialogs ( If that's what you mean ^^' )


Re: Command bug - Buzzbomb - 25.12.2011

Here An Example just Change the cordinates to ur gate location and Model ID IF there any errors please tell me.. I Included a description on what they do....


pawn Код:
#include <a_samp>
#include <streamer>

#define NEWSGATE_PASSWORD "/passwords/newsgate/password21.ini" // change that its the password but include "password21"
#define error 0xFF0000FF
#define normal 0xFFFFFFFF
forward GateClose(playerid);
new newsgate1;
new newsgate;
#define DIALOG_Gate_1

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public GateClose(playerid)
{
      MoveDynamicObject(newsgate1,777.52178955078, -1384.7537841797, 14.225526809692 , 0.97); /// This lines to close the gate
      PlayerPlaySound(playerid, 1153, 1589.053344,-1638.123168,14.122960); /// just a gate sound
      newsgate = 0;
      return 1;
}

public OnGameModeInit()
{
    newsgate1 = CreateDynamicObject(975, 777.52178955078, -1384.7537841797, 14.225526809692, 0, 0, 180.09997558594);//Make sure you put the closed gate here
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 777.52178955078, -1384.7537841797, 14.225526809692, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{ // I just use this here for shortcut to the Gate hehe
    SetPlayerPos(playerid, 777.52178955078, -1384.7537841797, 14.225526809692);
    SetPlayerCameraPos(playerid, 777.52178955078, -1384.7537841797, 14.225526809692);
    SetPlayerCameraLookAt(playerid, 777.52178955078, -1384.7537841797, 14.225526809692);
    return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/newsgate", cmdtext, true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 15.0,777.52178955078, -1384.7537841797, 14.225526809692)) // This is where player is in range of gate
            {
                ShowPlayerDialog(playerid, DIALOG_GATE_1, DIALOG_STYLE_INPUT, "Security Gate", "Hello How Are you Today, Please Punch In Your Passcode", "Open", "Cancel");
            }
            else
            {
                SendClientMessage(playerid, error, " Your Not Near The News Gate ");
            }
        }
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_GATE_1)
    {
        if(!response)
        {
            SendClientMessage(playerid, error, " Okay Access Denied Have a Nice Day!");
        }
        if(!strcmp(inputtext, NEWSGATE_PASSWORD, true))
        {
            SendClientMessage(playerid, error, "Invalid Passcode");
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Security Gate", "One More Chance, Please Punch In Your Passcode", "Open", "Cancel");
        }
        else
        {
            if(newsgate == 1) { SendClientMessage(playerid, error, "**  Security Gate is Open"); return 1; }
            MoveDynamicObject(newsgate1,769.52178955078, -1384.7537841797, 14.225526809692, 0.97); // to open the gate
            SetTimer("GateClose", 12000, 0); /// timer to close in 7 seconds
            new Gatemessage[64];
            format(Gatemessage, 64,"Security Gate will close in 7 seconds");
            GameTextForAll(Gatemessage, 5000, 3);
            PlayerPlaySound(playerid, 1153, 1589.053344,-1638.123168,14.122960);
            newsgate = 1;
        }
    }
    return 1;
}



Re: Command bug - HellviRus - 25.12.2011

Thank you but my system is a dynamic one
I transfered it to Dialogs and it worked. Thanks !


Re: Command bug - Buzzbomb - 25.12.2011

No Problem..