Need some help with windows command, It's prolly simple but i can't get it
#1

When i do /windows it rolls them down just fine, But when i do /windows again it rolls the windows down again, Why isn't it rolling them up like it's suppose to?

pawn Код:
if(!strcmp(cmd, "/windows", true) || !strcmp(cmd, "/wi", true))
        {
      if(IsPlayerConnected(playerid))
      {
        if(gPlayerLogged[playerid] == 0)
        {
          SendClientMessage(playerid, COLOR_GREY, " You need to login first ! ");
          return 1;
        }
        if(IsPlayerInAnyVehicle(playerid))
        {
          if(VehicleWindows[GetPlayerVehicleID(playerid)] == 0)
              {
                  VehicleWindows[GetPlayerVehicleID(playerid)] = 1;
                       GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "***%s rolls down the window.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                ShowNameTags(true);
                return 1;
                }
                else if(VehicleWindows[GetPlayerVehicleID(playerid)] == 1)
                {
                VehicleWindows[GetPlayerVehicleID(playerid)] = 0;
                       GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "***%s rolls up the window.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                ShowNameTags(false);
                return 1;
                }
                return 1;
        }
        else
        {
          SendClientMessage(playerid, COLOR_GREY, "  You need to be in the vehicle to use this function !");
          return 1;
        }
      }
      return 1;
    }
Reply
#2

Everything looks ok.
Whats your definition for VehicleWindows
Reply
#3

Quote:
Originally Posted by mansonh
Everything looks ok.
Whats your definition for VehicleWindows
pawn Код:
new VehicleWindows[MAX_VEHICLES] = 0;
that what you need?
Reply
#4

new VehicleWindows[MAX_VEHICLES] = 0;
new VehicleWindows[MAX_VEHICLES]; ? does that help
Reply
#5

It wouldn't change anything.
And for future note, "new VariabledArray[Size]=Number;" will only set the first cell (VariabledArray[0]) to the 'Number'. you have to do "new VariabledArray[Size]={Number,...};"

Here's your code re-indented and corrected... It should work
pawn Код:
if(!strcmp(cmd, "/windows", true) || !strcmp(cmd, "/wi", true))
{
  if(!gPlayerLogged[playerid])return SendClientMessage(playerid, COLOR_GREY, " You need to login first ! ");
  if(IsPlayerInAnyVehicle(playerid))
  {
    if(!VehicleWindows[GetPlayerVehicleID(playerid)])
    {
      VehicleWindows[GetPlayerVehicleID(playerid)] = 1;
      GetPlayerName(playerid, sendername, sizeof(sendername));
      format(string, sizeof(string), "***%s rolls down the window.", sendername);
      ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
      for(new ply;ply<MAX_PLAYERS;ply)ShowPlayerNameTagForPlayer(ply, playerid, false);
    }else{
      VehicleWindows[GetPlayerVehicleID(playerid)] = 0;
      GetPlayerName(playerid, sendername, sizeof(sendername));
      format(string, sizeof(string), "***%s rolls up the window.", sendername);
      ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
      for(new ply;ply<MAX_PLAYERS;ply)ShowPlayerNameTagForPlayer(ply, playerid, true);
    }
  }
  else return SendClientMessage(playerid, COLOR_GREY, "  You need to be in the vehicle to use this function !");
  return 1;
}
*edit, changed, I was using wrong function
Reply
#6

Whats the difference in your code that will make this work?
All i see different(related to his issue) on the two is if ! instead of == and the obviouse else instead of ==1?
Reply
#7

I'm not 100% sure if it works but when i compiled it i get

C:\Users\name\Desktop\sa-mp server\gamemodes\penls.pwn(7572) : warning 215: expression has no effect
C:\Users\name\Desktop\sa-mp server\gamemodes\penls.pwn(757 : warning 215: expression has no effect

it compiles fine just those warning, Thats on the

pawn Код:
for(new ply;ply<MAX_PLAYERS;ply)ShowPlayerNameTagForPlayer(ply, playerid, false);
Both lines with that in it.

Thank you for the help
Reply
#8

Код:
for(new ply;ply<MAX_PLAYERS;ply++)ShowPlayerNameTagForPlayer(ply, playerid, false);
Reply
#9

Quote:
Originally Posted by mansonh
Код:
for(new ply;ply<MAX_PLAYERS;ply++)ShowPlayerNameTagForPlayer(ply, playerid, false);
Beat me to it :P, but yeah that's it.
Reply
#10

Quote:
Originally Posted by mansonh
Код:
for(new ply;ply<MAX_PLAYERS;ply++)ShowPlayerNameTagForPlayer(ply, playerid, false);
That works, Thank you. Now i just gotta wait till i can get a friend on my server to test it out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)