Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Trabajo de Camionero [Crear y Guardar Localidades]
- By Parka
- Fecha de Desarrollo 03:19 a.m. 19/07/2013
- Version: 0.1a RC 1
- Introduccion
- El presente trabajo, es un sistema simple y completo para que usted pueda crear
- sus propias posiciones de cargamento y descarga automaticamente guardados en
- "scriptfiles/Trucking/Locations" para para cuando usted tenga la necesidad de
- reiniciar o cerrar el servidor no se pierdan las localidades, tambien dice hacia
- donde deves ir a llevar la carga.
- Desarrollo
- /Cargar
- Sirve para iniciar a trabajar de camionero, respectivamente con un trailer y un
- camion.
- /tutolc:
- este comando permite saber como usar el comando /crearlc.
- /crearlc <Jugador> :
- Usar /crearlc para crear una localidad en la cual el jugador va a transportar el trailer.
- Su posicion es donde inicia la Carga.
- Posicion del Jugador: Es donde se descargara el trailer.
- En este sistema los trailers son divididos en tres partes, el cual exigira nivel
- para poder cargar ese tipo de trailer.
- 1-Facil
- 2-Medio 4-6
- 3-Dificil 7 >
- Camionero:
- La restringcion esta basada en el skin del jugador por lo tanto para saber si es camionero
- debe poseer el skin de camionero que es la siguiente variable.
- SkinTruckDriver[4]
- */
- #include < a_samp >// SAMP-TEAM
- #include < sscanf2 >// Y_Less
- #include < A_ZONES >// By ~Cueball~
- #include < ZCMD >// Zeex
- #include < DINI >// DracoBlue
- #pragma unused ret_memcpy
- #pragma unused strtok
- #define Locations_Save "Trucking/Locations/%d.txt"
- #define Save_ID "Trucking/Quantidade.txt"
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 100
- new p_Get_Quantidade;
- new p_Quantidade;
- new p_ForID;
- new p_JopStatus[MAX_PLAYERS];
- new bool:p_Jop[MAX_PLAYERS];
- new Float:p_OldPos[MAX_PLAYERS][3];
- enum p_LAU
- {
- Float:Carregar_Posx,
- Float:Carregar_Posy,
- Float:Carregar_Posz,
- Float:Baixar_Posx,
- Float:Baixar_Posy,
- Float:Baixar_Posz
- }
- new LoadAndUnload[][p_LAU];
- new SkinTruckDriver[4] =
- {
- 133,
- 202,
- 206,
- 261
- };
- // ========[Trucking Job By Parka]======== //
- forward p_StopWork_LostTrailer( playerid );
- public p_StopWork_LostTrailer( playerid )
- {
- DisablePlayerCheckpoint(playerid);
- SendClientMessage(playerid, 0xFF0000AA, "Usted Perdio el Trailer,Se le descontara -$1000.");
- SendClientMessage(playerid, 0xFF0000AA, "Usted esta despedido.");
- GivePlayerMoney(playerid, -1000);
- p_JopStatus[playerid] = 0;
- p_Jop[ playerid ] = false;
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- forward p_StopWork( playerid );
- public p_StopWork( playerid )
- {
- DisablePlayerCheckpoint(playerid);
- SendClientMessage(playerid, 0xFF0000AA, "Usted escapo de su trabajo actual pierde -$1000");
- GivePlayerMoney(playerid, -1000);
- p_JopStatus[playerid] = 0;
- p_Jop[ playerid ] = false;
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- forward p_LoadAndUnload( playerid );
- public p_LoadAndUnload( playerid )
- {
- new v = GetPlayerVehicleID(playerid);
- new p_All, p_Pay, Float:p_THealth, Float:p_CHealth, string[256];
- GetVehicleHealth(v, p_CHealth);
- GetVehicleHealth(GetVehicleTrailer(v),p_THealth);
- switch(p_JopStatus[ playerid ])
- {
- case 1:
- {
- DisablePlayerCheckpoint( playerid );
- SetPlayerCheckpoint( playerid, p_OldPos[ playerid ][ 0 ], p_OldPos[ playerid ][ 1 ], p_OldPos[ playerid ][ 2 ], 7);
- SendClientMessage( playerid, 0xFFFF00AA, "Camion Cargado dirijase al punto de descarga.!");
- TogglePlayerControllable( playerid , true );
- p_JopStatus[ playerid ] = 2;
- }
- case 2:
- {
- switch(GetVehicleModel(GetVehicleTrailer(v)))
- {
- case 450://Easy Level 1 a 3
- {
- p_All = floatround(p_CHealth) + floatround(p_THealth);
- p_Pay = p_All * 2;
- format( string, sizeof string,
- "{00ff00}[!]==========[Detalles de Paga]==========[!]\n\
- {00ff00}Daños del Trailer: %d\n\
- {00ff00}Daños del Camion: %d\n\
- {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
- ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalles de Paga]", string, "Aceptar", "");
- GivePlayerMoney( playerid , p_Pay );
- TogglePlayerControllable( playerid , true );
- p_JopStatus[ playerid ] = 2;
- p_Jop [ playerid ] = true;
- }
- case 435,591://Medium Level 4 a 6
- {
- p_All = floatround(p_CHealth) + floatround(p_THealth);
- p_Pay = p_All * 3;
- format( string, sizeof string,
- "{00ff00}[!]==========[Detalles de Paga]==========[!]\n\
- {00ff00}Daños del Trailer: %d\n\
- {00ff00}Daños del Camion: %d\n\
- {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
- ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalles de Paga]", string, "Aceptar", "");
- GivePlayerMoney( playerid , p_Pay );
- TogglePlayerControllable( playerid , true );
- p_JopStatus[ playerid ] = 2;
- p_Jop [ playerid ] = true;
- }
- case 584://Hard Level 7 a 9
- {
- p_All = floatround(p_CHealth) + floatround(p_THealth);
- p_Pay = p_All * 4;
- format( string, sizeof string,
- "{00ff00}[!]==========[Detalles de Paga]==========[!]\n\
- {00ff00}Daños del Trailer: %d\n\
- {00ff00}Daños del Camion: %d\n\
- {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
- ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalles de Paga]", string, "Aceptar", "");
- GivePlayerMoney( playerid , p_Pay );
- TogglePlayerControllable( playerid , true );
- p_JopStatus[ playerid ] = 2;
- p_Jop [ playerid ] = true;
- }
- }
- }
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- forward GetTruckDriver( playerid );
- public GetTruckDriver( playerid )
- {
- for(new i; i < sizeof SkinTruckDriver; i++)
- {
- if( GetPlayerSkin(playerid) == SkinTruckDriver[i])
- {
- return 1;
- }
- }
- return 0;
- }
- // ========[Trucking Job By Parka]======== //
- forward PosForID();
- public PosForID()
- {
- if( dini_Exists( Save_ID ) )
- {
- p_Quantidade = dini_Int( Save_ID , "Quantidade" ) + 1;
- dini_IntSet( Save_ID , "Quantidade" , p_Quantidade );
- }
- return p_Quantidade;
- }
- // ========[Trucking Job By Parka]======== //
- forward PlayerStartWork( playerid );
- public PlayerStartWork( playerid )
- {
- new v = GetPlayerVehicleID(playerid);
- if(GetVehicleModel(v)==403||GetVehicleModel(v)==515||GetVehicleModel(v)==514)
- {
- if(IsTrailerAttachedToVehicle(v))
- {
- switch(GetVehicleModel(GetVehicleTrailer(v)))
- {
- case 450://Easy Level 1 a 3
- {
- SetPosDestination( playerid );
- }
- case 435,591://Medium Level 4 a 6
- {
- if(GetPlayerScore(playerid) <= 3) return SendClientMessage( playerid, 0xFF0000AA, "Usted debe ser nivel 4 para transportar carga media");
- SetPosDestination( playerid );
- }
- case 584://Hard Level 7 a 9
- {
- if(GetPlayerScore(playerid) <= 6) return SendClientMessage( playerid, 0xFF0000AA, "Usted debe ser nivel 7 para transportar carga pesada");
- SetPosDestination( playerid );
- }
- }
- }else return SendClientMessage( playerid, 0xFF0000AA, "Usted no tiene un trailer enganchado");
- }
- else return SendClientMessage( playerid, 0xFF0000AA, "Usted debe estar dentro de un camion");
- return true;
- }
- // ========[Trucking Job By Parka]======== //
- forward SetPosDestination( playerid );
- public SetPosDestination( playerid )
- {
- if( dini_Exists( Save_ID ) )
- {
- p_Get_Quantidade = dini_Int( Save_ID , "Quantidade");
- }
- new p_random = random(p_Get_Quantidade);
- new Float:p_LastPos[MAX_PLAYERS][3];
- new string[32];
- format( string, sizeof string, Locations_Save, p_random);
- if( !dini_Exists( string ) )
- return SendClientMessage( playerid, 0xFF0000AA, "Contacta a un administrador si esto aparece.!");
- LoadAndUnload[ p_random ][ Carregar_Posx] = dini_Float ( string, "Carregar_X");
- LoadAndUnload[ p_random ][ Carregar_Posy] = dini_Float ( string, "Carregar_Y");
- LoadAndUnload[ p_random ][ Carregar_Posz] = dini_Float ( string, "Carregar_Z");
- LoadAndUnload[ p_random ][ Baixar_Posx] = dini_Float ( string, "Baixar_X" );
- LoadAndUnload[ p_random ][ Baixar_Posy] = dini_Float ( string, "Baixar_Y" );
- LoadAndUnload[ p_random ][ Baixar_Posz] = dini_Float ( string, "Baixar_Z" );
- p_LastPos[ playerid ][ 0 ] = LoadAndUnload[ p_random ][ Carregar_Posx ];
- p_LastPos[ playerid ][ 1 ] = LoadAndUnload[ p_random ][ Carregar_Posy ];
- p_LastPos[ playerid ][ 2 ] = LoadAndUnload[ p_random ][ Carregar_Posz ];
- p_OldPos[ playerid ][ 0 ] = LoadAndUnload[ p_random ][ Baixar_Posx ];
- p_OldPos[ playerid ][ 1 ] = LoadAndUnload[ p_random ][ Baixar_Posy ];
- p_OldPos[ playerid ][ 2 ] = LoadAndUnload[ p_random ][ Baixar_Posz ];
- SetPlayerCheckpoint(playerid, p_LastPos[ playerid ][ 0 ], p_LastPos[ playerid ][ 1 ], p_LastPos[ playerid ][ 2 ], 7);
- new StrIng_Text[256];
- format( StrIng_Text, sizeof StrIng_Text, "%s", dini_Get( string, "Localidade"));
- SendClientMessage( playerid, 0x00FF00AA, StrIng_Text);
- p_JopStatus[ playerid ] = 1;
- p_Jop [ playerid ] = true;
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- forward SaveLocations( LocationName[], Float:Carregar_x, Float:Carregar_y, Float:Carregar_z, Float:Baixar_x, Float:Baixar_y, Float:Baixar_z );
- public SaveLocations( LocationName[], Float:Carregar_x, Float:Carregar_y, Float:Carregar_z, Float:Baixar_x, Float:Baixar_y, Float:Baixar_z )
- {
- if(!dini_Exists(TKSave()))
- {
- dini_Create ( TKSave());
- dini_Set ( TKSave(), "Localidade", LocationName);
- dini_FloatSet ( TKSave(), "Carregar_X", Carregar_x );
- dini_FloatSet ( TKSave(), "Carregar_Y", Carregar_y );
- dini_FloatSet ( TKSave(), "Carregar_Z", Carregar_z );
- dini_FloatSet ( TKSave(), "Baixar_X" , Baixar_x );
- dini_FloatSet ( TKSave(), "Baixar_Y" , Baixar_y );
- dini_FloatSet ( TKSave(), "Baixar_Z" , Baixar_z );
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- stock TKSave()
- {
- new string[32];
- format( string, sizeof string, Locations_Save, p_ForID);
- return string;
- }
- // ========[Trucking Job By Parka]======== //
- CMD:crearlc(playerid,params[])
- {
- if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, 0xFF0000AA, "Usted no es administrador /RCON");
- new Target;
- if( sscanf( params, "d", Target) ) return SendClientMessage( playerid, 0xFF0000AA, "Use: '/crearlc <Jugador>' Ayuda = (/tutolc)");
- if( !IsPlayerConnected(Target) || Target == INVALID_PLAYER_ID ) return SendClientMessage( playerid, 0xFF0000AA, "Jugador no esta conectado");
- if( Target == playerid ) return SendClientMessage( playerid, 0xFF0000AA, "No puedes ser tu mismo.!");
- new Float:TargetPos[3];
- new Float:PlayerPos[3];
- GetPlayerPos( playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
- GetPlayerPos( Target, TargetPos[0], TargetPos[1], TargetPos[2]);
- p_ForID = PosForID();
- new Zone_Target[32];
- new Zone_Player[32];
- GetPlayer3DZone( Target, Zone_Target, 32);
- GetPlayer3DZone( playerid, Zone_Player, 32);
- new Str_Ing[256];
- format( Str_Ing, sizeof Str_Ing, "Localidad: Cargar en %s y descargar en %s", Zone_Player, Zone_Target);
- SaveLocations( Str_Ing, PlayerPos[0], PlayerPos[1], PlayerPos[2], TargetPos[0], TargetPos[1], TargetPos[2] );
- SendClientMessage( playerid, 0x00FF00AA, "La localidad se creo automaticamnete.");
- SendClientMessage( Target, 0x00FF00AA, "La localidad se creo automaticamnete.");
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- CMD:tutolc(playerid,params[])
- {
- SendClientMessage( playerid, 0xFFFF00AA, "Usar /crearlc para crear una localidad en la cual el jugador va a transportar el trailer.");
- SendClientMessage( playerid, 0xFFFF00AA, "Su posicion es donde inicia la Carga.");
- SendClientMessage( playerid, 0xFFFF00AA, "Posicion del Jugador: Es donde se descargara el trailer.");
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- CMD:cargar(playerid,params[])
- {
- if( IsPlayerConnected( playerid ) )
- {
- if( p_Jop[ playerid ] == false )
- {
- if(GetTruckDriver(playerid))
- {
- PlayerStartWork( playerid );
- }
- else return SendClientMessage( playerid, 0xFF0000AA, "Usted no es Camionero.");
- }
- else return SendClientMessage( playerid, 0xFF0000AA, "Usted ya esta trabajando.");
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- public OnFilterScriptInit()
- {
- if( !dini_Exists( Save_ID ) )
- {
- dini_Create( Save_ID );
- dini_IntSet( Save_ID , "Quantidade" , -1);
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- public OnPlayerConnect(playerid)
- {
- p_Jop [ playerid ] = false;
- p_JopStatus[ playerid ] = 0;
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- public OnPlayerEnterCheckpoint(playerid)
- {
- if( IsPlayerConnected( playerid ) )
- {
- switch(p_JopStatus[ playerid ])
- {
- case 1:
- {
- GameTextForPlayer( playerid, "~y~~h~Cargando Productos~n~~p~Espere por favor..", 10000, 1);
- TogglePlayerControllable( playerid, false);
- SetTimerEx("p_LoadAndUnload", 10000, false, "d", playerid);
- }
- case 2:
- {
- GameTextForPlayer( playerid, "~g~~h~Descargando Productos~n~~p~Espere por favor..", 10000, 1);
- TogglePlayerControllable( playerid, false);
- SetTimerEx("p_LoadAndUnload", 10000, false, "d", playerid);
- }
- }
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- public OnPlayerLeaveCheckpoint(playerid)
- {
- if( IsPlayerConnected( playerid ) )
- {
- DisablePlayerCheckpoint(playerid);
- }
- return 1;
- }
- // ========[Trucking Job By Parka]======== //
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new v = GetPlayerVehicleID(playerid);
- if(!IsTrailerAttachedToVehicle(v) && p_JopStatus[ playerid ] >= 1)
- {
- p_StopWork_LostTrailer(playerid);
- }
- return 1;
- }
- /*
- Trabajo de Camionero [Crear y Guardar Localidades]
- By Parka
- Fecha de Desarrollo 03:19 a.m. 19/07/2013
- Version: 0.1a RC 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement