SA-MP Forums Archive
Whats wrong? - 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: Whats wrong? (/showthread.php?tid=365076)



Whats wrong? - Vizi - 01.08.2012

Whats wrong with this this is a command for lights
It is not working on the server :S
pawn Код:
//------------------------------------------------------------------------------
    if(strcmp(cmd,"/svetla", true) == 0)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
      if(IsPlayerConnected(playerid))
      {
        if(Svetla[playerid] == 0)
        {
            GetPlayerNameEx(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "%s gi pusti svetlata.", sendername);
            ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SendClientMessage(playerid, WHITE, "{37F906}INFO:{FFFFFF}Gi pustivte svetlata.");
            GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,1,alarm,doors,bonnet,boot,objective);
            Svetla[playerid] = 1;
            return 1;
        }
        else
        {
          GetPlayerNameEx(playerid, sendername, sizeof(sendername));
          format(string, sizeof(string), "%s gi iskluci svetlata.", sendername);
          ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
          SendClientMessage(playerid, WHITE, "{37F906}INFO:{FFFFFF}Gi izklucivte svetlata.");
          GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
          SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,0,alarm,doors,bonnet,boot,objective);
          Svetla[playerid] = 0;
          return 1;
        }
      }
     }
     return 1;
    }
I have
pawn Код:
new Svetla[MAX_PLAYERS];



Re: Whats wrong? - Vizi - 01.08.2012

pleaseee i need for friday !


Re: Whats wrong? - Vizi - 01.08.2012

Sorry for spam BUT HELP MEEEEEE!!!! Wht the command is not working in server ??


Re: Whats wrong? - Misiur - 01.08.2012

First of all: OnPlayerCommandText should to return 0 if no command is found.
Secondly: What do you mean by it's not working. It's a wide term. Is anything shown to player? Or nothing happens at all?


Re: Whats wrong? - Vizi - 01.08.2012

when I'm in the car and i write /svetla nothing hapent the lights not turned on


Re: Whats wrong? - Misiur - 01.08.2012

try something like
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
    /* Remember to create all necessary variables here */
    if(!strcmp(cmdtext, "/svetla", true))
    {
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, RED, "Player not connected");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "Player not in vehicle");
        GetPlayerNameEx(playerid, sendername, sizeof(sendername));
        if(Svetla[playerid] == 0)
        {
            format(string, sizeof(string), "%s gi pusti svetlata.", sendername);
            ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SendClientMessage(playerid, WHITE, "{37F906}INFO:{FFFFFF}Gi pustivte svetlata.");
            GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,1,alarm,doors,bonnet,boot,objective);
            Svetla[playerid] = 1;
        }
        else
        {
            format(string, sizeof(string), "%s gi iskluci svetlata.", sendername);
            ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            SendClientMessage(playerid, WHITE, "{37F906}INFO:{FFFFFF}Gi izklucivte svetlata.");
            GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, 0, alarm, doors, bonnet, boot, objective);
            Svetla[playerid] = 0;
        }
        return 1;
    }
    return 0;
}



Re: Whats wrong? - Vizi - 01.08.2012

i have errors

pawn Код:
F:\Users\Daniel\Desktop\GamingClub RP\gamemodes\DreamWorld.pwn(12593) : error 029: invalid expression, assumed zero
F:\Users\Daniel\Desktop\GamingClub RP\gamemodes\DreamWorld.pwn(12593) : error 029: invalid expression, assumed zero



Re: Whats wrong? - Vizi - 02.08.2012

Come onnnnn i know that you know how to fix !!


Re: Whats wrong? - Misiur - 02.08.2012

Yup, but I need your lines 12500 to 12700


Re: Whats wrong? - [MM]RoXoR[FS] - 02.08.2012

Your code is FINE

Add this under OnGameModeInit()
pawn Код:
ManualVehicleEngineAndLights();
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger == 0)
    {
     new engine, lights, alarm, doors, bonnet, boot, objective;
     GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
     SetVehicleParamsEx(vehicleid, 1,   lights,    alarm, doors, bonnet, boot, objective);
    }
    return 1;
}