SA-MP Forums Archive
Need some help with windows command, It's prolly simple but i can't get it - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need some help with windows command, It's prolly simple but i can't get it (/showthread.php?tid=126239)



Need some help with windows command, It's prolly simple but i can't get it - ihatetn931 - 07.02.2010

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;
    }



Re: Need some help with windows command, It's prolly simple but i can't get it - mansonh - 07.02.2010

Everything looks ok.
Whats your definition for VehicleWindows


Re: Need some help with windows command, It's prolly simple but i can't get it - ihatetn931 - 07.02.2010

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


Re: Need some help with windows command, It's prolly simple but i can't get it - mansonh - 07.02.2010

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


Re: Need some help with windows command, It's prolly simple but i can't get it - Joe Staff - 07.02.2010

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


Re: Need some help with windows command, It's prolly simple but i can't get it - mansonh - 07.02.2010

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?



Re: Need some help with windows command, It's prolly simple but i can't get it - ihatetn931 - 07.02.2010

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


Re: Need some help with windows command, It's prolly simple but i can't get it - mansonh - 07.02.2010

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



Re: Need some help with windows command, It's prolly simple but i can't get it - Joe Staff - 07.02.2010

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.


Re: Need some help with windows command, It's prolly simple but i can't get it - ihatetn931 - 07.02.2010

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