Command bug
#1

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 !
Reply
#2

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
Reply
#3

Ok I'll try it . Thanks
Reply
#4

Did it work..
Reply
#5

No ... The same error.
Reply
#6

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

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

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;
}
Reply
#9

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

No Problem..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)