What's wrong with this command?
#1

pawn Код:
if(strcmp(cmd, "/pddoor", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (!pddoor))
            {
                pddoor = 1;
                gate = 4;
                MoveDynamicObject(3, 248.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 243.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s takes out a key, and unlocks the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(string, sizeof(string), "* %s opens the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
            {
                pddoor = 0;
                MoveDynamicObject(3, 247.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 244.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s closes the door. *It Auto Locks*", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not a police officer!");
            }
        }
        return 1;
    }
When i use it, it comes up with these errors :

Quote:

C:\Documents and Settings\Eric\Desktop\NH-RP2\NHRP Server\gamemodes\nhrp.pwn(21639) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Eric\Desktop\NH-RP2\NHRP Server\gamemodes\nhrp.pwn(21639) : warning 215: expression has no effect
C:\Documents and Settings\Eric\Desktop\NH-RP2\NHRP Server\gamemodes\nhrp.pwn(21639) : error 001: expected token: ";", but found "if"

Any help is greatly appreciated!

- Eric
Reply
#2

What is the line 21639?
Reply
#3

pawn Код:
else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
That one; The second one, where its shutting the door.
Reply
#4

Quote:
Originally Posted by Tnt12340
pawn Код:
else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
That one; The second one, where its shutting the door.
pawn Код:
else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor));
Copy&past this line into your old line.

You forgot to add a ";"
Reply
#5

@Flashy, You fail so much.

@Tnt12340,
You can't do it like that. If you use else if it needs to be resume of another if condition.
Код:
			}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
			{
Reply
#6

Sooo err..

Like this? I'm new to scripting btw, so i may seem like a nub :P

pawn Код:
if(strcmp(cmd, "/pddoor", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (!pddoor))
            {
                pddoor = 1;
                gate = 4;
                MoveDynamicObject(3, 248.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 243.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s takes out a key, and unlocks the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(string, sizeof(string), "* %s opens the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
            {
            {
                pddoor = 0;
                MoveDynamicObject(3, 247.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 244.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s closes the door. *It Auto Locks*", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not a police officer!");
            }
        }
        return 1;
    }
Reply
#7

Quote:
Originally Posted by Tnt12340
Sooo err..

Like this? I'm new to scripting btw, so i may seem like a nub :P

pawn Код:
if(strcmp(cmd, "/pddoor", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (!pddoor))
            {
                pddoor = 1;
                gate = 4;
                MoveDynamicObject(3, 248.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 243.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s takes out a key, and unlocks the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(string, sizeof(string), "* %s opens the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
            {
            {
                pddoor = 0;
                MoveDynamicObject(3, 247.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 244.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s closes the door. *It Auto Locks*", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not a police officer!");
            }
        }
        return 1;
    }
Why twice GetPlayerName?
pawn Код:
if(strcmp(cmd, "/pddoor", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (!pddoor))
            {
                pddoor = 1;
                gate = 4;
                MoveDynamicObject(3, 248.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 243.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s takes out a key, and unlocks the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                format(string, sizeof(string), "* %s opens the door.", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
            {
                pddoor = 0;
                MoveDynamicObject(3, 247.880111, 72.445343, 1002.560546,5);
                MoveDynamicObject(4, 244.894638, 72.445343, 1002.560546,5);
                format(string, sizeof(string), "* %s closes the door. *It Auto Locks*", sendername);
                ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not a police officer!");
            }
        }
        return 1;
    }
Reply
#8

Quote:
Originally Posted by $ЂЯĢ
@Flashy, You fail so much.

@Tnt12340,
You can't do it like that. If you use else if it needs to be resume of another if condition.
Код:
			}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			else if(IsACop(playerid) && IsPlayerInSphere(playerid,246.3890,72.0390,1003.6406,4) && (pddoor))
			{
I donґt know what you want, but I had the same problem. I fixed it after adding ; so stfu.
Reply
#9

Works like a charm! Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)