Professional Documents
Culture Documents
Trabajo para El SENA
Trabajo para El SENA
Credits:-
__________
#define MAX_FOOD (100) // Maximum to load from database, you may change
that.
//Prices
#define PIZZA_PRICE (10)
#define FRIES_PRICE (5)
#define COLA_PRICE (2)
#define BURGER_PRICE (10)
#define HOTDOG_PRICE (10)
enum FoodData
{
id,
fmodelid,
fcheckpointid,
text[32],
Text3D:textid,
Float:ObjPosX,
Float:ObjPosY,
Float:ObjPosZ,
Float:ObjRotX,
Float:ObjRotY,
Float:ObjRotZ,
ActorID,
ActorSkin,
Float:ActorX,
Float:ActorY,
Float:ActorZ,
Float:ActorRot
};
new
FoodInfo[ MAX_FOOD ][FoodData ],
DB:f_database,
Iterator:Foods<MAX_FOOD>,
Text:Foodobj[15],
bool:Isviewingobj[MAX_PLAYERS],
PlayerAttachedObject[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Dynamic fast food system loaded");
print("--------------------------------------\n");
new
Query[ 23 ],
DBResult: Result,
str[ 64 ],
fid;
format( Query, sizeof( Query ) , "SELECT * FROM food" );
Result = db_query( f_database, Query );
if (db_num_rows(Result))
{
db_next_row(Result);
print("\n==========================================================================
=");
printf( "[FOOD SYSTEM]: Loaded (%i) from the
database.",db_num_rows(Result) );
print("============================================================================
=\n");
db_free_result(Result);
}
Foodobj[1] = TextDrawCreate(192.699951, 118.449996, "");
TextDrawLetterSize(Foodobj[1], 0.000000, 0.000000);
TextDrawTextSize(Foodobj[1], 248.000000, 209.000000);
TextDrawAlignment(Foodobj[1], 1);
TextDrawColor(Foodobj[1], 255);
TextDrawSetShadow(Foodobj[1], 0);
TextDrawSetOutline(Foodobj[1], 0);
TextDrawBackgroundColor(Foodobj[1], 0);
TextDrawFont(Foodobj[1], 5);
TextDrawSetProportional(Foodobj[1], 0);
TextDrawSetShadow(Foodobj[1], 0);
TextDrawSetPreviewModel(Foodobj[1], 1895);
TextDrawSetPreviewRot(Foodobj[1], 0.000000, 0.000000, 0.000000, 1.000000);
public OnFilterScriptExit()
{
for( new o = 0; o < 15; o++ )
{
TextDrawDestroy( Foodobj[o] );
}
for( new p = 0; p < MAX_FOOD; p ++ )
{
if( IsValidDynamicObject( FoodInfo[ p ] [ id ] ) )
{ DestroyDynamicObject( FoodInfo[ p ] [ id ] ); }
if( IsValidDynamicCP( FoodInfo[ p ] [ fcheckpointid ] ) )
{ DestroyDynamicCP( FoodInfo[ p ] [ fcheckpointid ] ); }
if( IsValidDynamic3DTextLabel( FoodInfo[ p ] [ textid ] ) )
{ DestroyDynamic3DTextLabel( FoodInfo[ p ] [ textid ] ); }
DestroyActor( FoodInfo[ p ] [ ActorID ] );
}
return true;
}
public OnPlayerConnect(playerid)
{
EnablePlayerCameraTarget(playerid, true);
return true;
}
public OnPlayerSpawn(playerid)
{
PreloadAnimLib( playerid, "FOOD" );
PreloadAnimLib( playerid, "DEALER" );
PreloadAnimLib( playerid, "VENDING" );
return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 122 )
{
if(response)
{
switch( listitem )
{
case 0:
{
new
objects[ 3 ];
objects [ 0 ] = 1340, objects[ 1 ] = 956,
objects[ 2 ] = 1776;//you may add all the objects you want
ShowModelSelectionMenuEx(playerid, objects, 3, "Select
object model", 124, 16.0, 0.0, 180.0, 1.0, 0x00000033, 0x00000066, 0xA1A1A133);
}
case 1:
{
new
str[ 256 ];
for( new i = 0; i < MAX_FOOD; i++ )
{
if( IsValidDynamicObject( FoodInfo[ i ]
[ id ] ) )
{
format( str, sizeof( str ), "%s %s [ID:%d]\n",
str, FoodInfo[ i ] [ text ], i );
}
}
ShowPlayerDialog( playerid, 0, DIALOG_STYLE_LIST,
"Information", str, "Ok","" );
}
case 2:
{
ShowPlayerDialog( playerid, 124, DIALOG_STYLE_INPUT,
"Type the ID", "Type the ID you would like to teleport there", "Ok","" );
}
case 3:
{
ShowPlayerDialog( playerid, 125, DIALOG_STYLE_INPUT, "Type
the ID","Please type the ID of the desired one to be deleted\nNOTE: its found on
the object", "Ok", "Back" );
}
}
}
}
if( dialogid == 123 )
{
if( ! response ) return ShowPlayerDialog( playerid, 123,
DIALOG_STYLE_INPUT, "Type text", "Type here the text you would like to attach to
the object\n{FF0000}You can't skip this! its obligatory", "Ok", "");
if( response )
{
new
str[ 64 ], query[ 520 ], f_id;
f_id = Iter_Free(Foods);
format( str, sizeof( str ) , "%s\nID(%d)", inputtext, f_id );
FoodInfo[ f_id] [ textid ] = CreateDynamic3DTextLabel( str, -1,
FoodInfo[ f_id ] [ ObjPosX ], FoodInfo[ f_id ] [ ObjPosY ], FoodInfo[ f_id ]
[ ObjPosZ ], 10.0 );
format(FoodInfo[ f_id ] [ text ], 32, "%s", inputtext);
format( query , sizeof( query ) , "INSERT INTO food (id, modelid,
text, x, y, z, rotx, roty, rotz, Actorskin, ActorX, ActorY, ActorZ , ActorRot)
VALUES (%d, %d, '%s', %f, %f, %f, %f, %f, %f, %d, %f, %f, %f, %f)",\
f_id,
FoodInfo[ f_id ] [ fmodelid ],
inputtext ,
FoodInfo[ f_id ] [ ObjPosX ] ,
FoodInfo[ f_id ] [ ObjPosY ],
FoodInfo[ f_id ] [ ObjPosZ ],
FoodInfo[ f_id ] [ ObjRotX ],
FoodInfo[ f_id ] [ ObjRotY ],
FoodInfo[ f_id ] [ ObjRotZ ],
FoodInfo[ f_id ] [ ActorSkin ] ,
FoodInfo[ f_id ] [ ActorX ],
FoodInfo[ f_id ] [ ActorY ],
FoodInfo[ f_id ] [ ActorZ ],
FoodInfo[ f_id ] [ ActorRot ] );
Iter_Add(Foods, f_id);
}
}
if( dialogid == 124 )
{
if( response )
{
new
f_id = strval(inputtext);
if(! strval( inputtext ) ) return SendClientMessage( playerid,
0xFF0000FF, "[ERROR]{FFFFFF} You must enter numbers only" );
if( !IsValidDynamicObject( FoodInfo[ f_id ] [ id ] )) return
SendClientMessage( playerid, 0xFF0000FF, "[ERROR]{FFFFFF} That object does not
exist!" );
new
Float:x, Float:y, Float:z;
GetDynamicObjectPos( FoodInfo[ strval(inputtext) ] [ id ] , x, y, z
);
SetPlayerPos( playerid, x+2.0, y+1.0,z );
GameTextForPlayer( playerid, "~b~~h~Teleported!", 2000, 3 );
}
}
if( dialogid == 125 )
{
if(response)
{
new
f_id = strval(inputtext);
if(!Iter_Contains(Foods, f_id)) return SendClientMessage( playerid,
0x00B503FF, "[INFO]{FFFFFF} Please type the number only (0-99)" );
if( !IsValidDynamicObject( FoodInfo[ f_id ] [ id ] )) return
SendClientMessage( playerid, 0xFF0000FF, "[ERROR]{FFFFFF} That object does not
exist!" );
new
actorid = GetPlayerCameraTargetActor(playerid);
ApplyActorAnimation( actorid , "DEALER" , "shop_pay" , 4.0 , 0 , 0 ,
0 , 0 , 0 );
}
if ( clickedid == Foodobj[7] )
{
if( GetPlayerMoney( playerid ) < FRIES_PRICE ) return
SendClientMessage( playerid, 0xFF0000FF, "[ERROR]{FFFFFF} You don't have money to
buy that food" );
GivePlayerMoney( playerid, - FRIES_PRICE );
SetPlayerArmedWeapon(playerid,0);
HidefoodTD( playerid );
new
actorid = GetPlayerCameraTargetActor(playerid);
ApplyActorAnimation( actorid , "DEALER" , "shop_pay" , 4.0 , 0 , 0 ,
0 , 0 , 0 );
}
if ( clickedid == Foodobj[9] )
{
if( GetPlayerMoney( playerid ) < COLA_PRICE ) return
SendClientMessage( playerid, 0xFF0000FF, "[ERROR]{FFFFFF} You don't have money to
buy that food" );
GivePlayerMoney( playerid, - COLA_PRICE );
SetPlayerArmedWeapon(playerid,0);
HidefoodTD( playerid );
new
actorid = GetPlayerCameraTargetActor(playerid);
ApplyActorAnimation( actorid , "DEALER" , "shop_pay" , 4.0 , 0 , 0 ,
0 , 0 , 0 );
}
if ( clickedid == Foodobj[11] )
{
if( GetPlayerMoney( playerid ) < BURGER_PRICE ) return SendClientMessage(
playerid, 0xFF0000FF, "[ERROR]{FFFFFF} You don't have money to buy that food" );
GivePlayerMoney( playerid, - BURGER_PRICE );
SetPlayerArmedWeapon(playerid,0);
HidefoodTD( playerid );
new
actorid = GetPlayerCameraTargetActor(playerid);
ApplyActorAnimation( actorid , "DEALER" , "shop_pay" , 4.0 , 0 , 0 ,
0 , 0 , 0 );
}
if ( clickedid == Foodobj[13] )
{
if( GetPlayerMoney( playerid ) < HOTDOG_PRICE ) return SendClientMessage(
playerid, 0xFF0000FF, "[ERROR]{FFFFFF} You don't have money to buy that food" );
GivePlayerMoney( playerid, - HOTDOG_PRICE );
HidefoodTD( playerid );
new
actorid = GetPlayerCameraTargetActor(playerid);
ApplyActorAnimation( actorid , "DEALER" , "shop_pay" , 4.0 , 0 , 0 ,
0 , 0 , 0 );
}
return true;
}
forward RemoveObject( playerid );
public RemoveObject( playerid )
{
new
Float:h;
GetPlayerHealth( playerid, h );
printf("health %f", h);
RemovePlayerAttachedObject( playerid, PlayerAttachedObject[ playerid ] );
ClearAnimations( playerid );
if( h < 100 && h >= 89 )
{
SetPlayerHealth( playerid, 100 );
}
if( h < 89)
{
SetPlayerHealth( playerid, h+10 );
}
}
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y,
Float:z, Float:rx, Float:ry, Float:rz)
{
new f_id;
f_id = Iter_Free(Foods);
if( objectid == FoodInfo[ f_id ] [ id ] )
{
if( response == EDIT_RESPONSE_UPDATE )
{
SetDynamicObjectPos( objectid, x, y, z );
SetDynamicObjectRot( objectid, rx, ry, rz );// to update it so others
may see it.
}
if ( response == EDIT_RESPONSE_FINAL )
{
FoodInfo[ f_id ] [ id ]= objectid;
}
SelectTextDraw(playerid, 0x00FF00FF);
}
HidefoodTD( playerid )
{
for ( new i = 0; i < 15; i ++ )
{
TextDrawHideForPlayer( playerid, Foodobj[ i ] );
}
CancelSelectTextDraw(playerid);
}
new Float:a;
GetActorPos(actorid, x, y, a);
GetActorFacingAngle(actorid, a);