SA-MP Forums Archive
my code is big? - 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: my code is big? (/showthread.php?tid=192522)



my code is big? - oOegyptOo - 22.11.2010

i think my code big O-o any way to make it shorter or its ok?

PHP код:
    if(!strcmp("/work"cmdtexttrue))
    {
        if (
minfo[playerid][CheckpointID] == 0)
        {
            new 
pvehiclemodel GetVehicleModel(GetPlayerVehicleID(playerid));
            if (
pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515)
            {
                if (
IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
                {
                    new 
string[200];
                    new 
rand random(sizeof(TruckingMissionRandom));
                    
CreatePlayerMission(playeridTruckingMissionRandom[rand][UseTrailerCheck], TruckingMissionRandom[rand][MissionPay], TruckingMissionRandom[rand][loadx],TruckingMissionRandom[rand][loady], TruckingMissionRandom[rand][loadz], TruckingMissionRandom[rand][unloadx],TruckingMissionRandom[rand][unloady], TruckingMissionRandom[rand][unloadz]);
                    
format(stringsizeof(string), "You are doing mission: %s"TruckingMissionRandom[rand][MissionName]);
                    
SendClientMessage(playerid0x00FF00FFstring);
                }
                else
                {
                    
SendClientMessage(playerid0xFF0000AA"Im sorry but this mission requires that you use a vehicle that can pull a semi trailer Ex: Roadtrain with an Artict1!");
                }
            }
            else
            {
            
SendClientMessage(playerid0xFF0000AA"you need truck and tailer to be able to work");
            }
        }
        else
        {
        
SendClientMessage(playerid0xFF0000AA"you already have work");
        }
        return 
1;
    } 



Re: my code is big? - FreshDoubleX - 22.11.2010

Change your CreatePlayerMission line smaller:
pawn Код:
CreatePlayerMission(playerid, TruckingMissionRandom[rand][UseTrailerCheck],
TruckingMissionRandom[rand][MissionPay],
TruckingMissionRandom[rand][loadx],
TruckingMissionRandom[rand][loady],
TruckingMissionRandom[rand][loadz],
TruckingMissionRandom[rand][unloadx],
TruckingMissionRandom[rand][unloady],
TruckingMissionRandom[rand][unloadz]);



Re: my code is big? - The_Gangstas - 22.11.2010

pawn Код:
if(!strcmp("/work", cmdtext, true))
{
    if (minfo[playerid][CheckpointID] != 0) return SendClientMessage(playerid, 0xFF0000AA, "you already have work");
    new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
    if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515) else { return SendClientMessage(playerid, 0xFF0000AA, "you need truck and tailer to be able to work");}
    if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000AA, "This Mission Requres You To Have A Trailer Attached To Your Truck.");
    new string[128];
    new rand = random(sizeof(TruckingMissionRandom));
    CreatePlayerMission(playerid, TruckingMissionRandom[rand][UseTrailerCheck], TruckingMissionRandom[rand][MissionPay], TruckingMissionRandom[rand][loadx],TruckingMissionRandom[rand][loady], TruckingMissionRandom[rand][loadz],
    TruckingMissionRandom[rand][unloadx],TruckingMissionRandom[rand][unloady], TruckingMissionRandom[rand][unloadz]);
    format(string, sizeof(string), "You are doing mission: %s", TruckingMissionRandom[rand][MissionName]);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}



Re: my code is big? - oOegyptOo - 22.11.2010

oO ur big


Re: my code is big? - oOegyptOo - 22.11.2010

Quote:
Originally Posted by The_Gangstas
Посмотреть сообщение
pawn Код:
if(!strcmp("/work", cmdtext, true))
{
    if (minfo[playerid][CheckpointID] != 0) return SendClientMessage(playerid, 0xFF0000AA, "you already have work");
    new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
    if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515) else { return SendClientMessage(playerid, 0xFF0000AA, "you need truck and tailer to be able to work");}
    if (!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xFF0000AA, "Im sorry but this mission requires that you use a vehicle that can pull a semi trailer Ex: Roadtrain with an Artict1!");
    new string[128];
    new rand = random(sizeof(TruckingMissionRandom));
    CreatePlayerMission(playerid, TruckingMissionRandom[rand][UseTrailerCheck], TruckingMissionRandom[rand][MissionPay], TruckingMissionRandom[rand][loadx],TruckingMissionRandom[rand][loady], TruckingMissionRandom[rand][loadz],
    TruckingMissionRandom[rand][unloadx],TruckingMissionRandom[rand][unloady], TruckingMissionRandom[rand][unloadz]);
    format(string, sizeof(string), "You are doing mission: %s", TruckingMissionRandom[rand][MissionName]);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}
really thanks


Re: my code is big? - FreshDoubleX - 22.11.2010

Oh Yes, Thats if whole code is small, I thought that you had error because of too big line
Anyways, Good Luck !


Re: my code is big? - Steven82 - 22.11.2010

Your code aint that big. I once had a cmd on a script that used almost 150 lines.