Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Experimental FS by adri1
- //==============================================================================
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- new ob, st, count, rotob, angleob,
- Float:Vel = 10.0, Float:angle = 0.0, Float:rotation = 0.0, Float:gravity = 9.8,
- Float:VelX, Float:VelY,
- Text:TDEditor_TD;
- #define INITIAL_X 0.0
- #define INITIAL_Y 0.0
- #define INITIAL_Z 50.0
- public OnFilterScriptInit()
- {
- ob = CreateObject(1946, INITIAL_X, INITIAL_Y, INITIAL_Z, 0.00000, 0.00000, 0.00000, 1000.0);
- CreateObject(19757, 0.00000, 0.00000, 50.00000, 0.00000, 0.00000, 0.00000, 1000.0);
- CreateObject(19757, 0.00000, 0.00000, 50.00000, 90.00000, 0.00000, 0.00000, 1000.0);
- CreateObject(19757, 0.00000, 0.00000, 50.00000, 90.00000, 90.00000, 0.00000, 1000.0);
- SetObjectMaterial(CreateObject(18981, 0.00000, 0.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0), 0, 18646, "matcolours", "yellow");
- CreateObject(18981, 25.00000, 0.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0);
- CreateObject(18981, 0.00000, 25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0);
- CreateObject(18981, 0.00000, -25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0);
- CreateObject(18981, -25.00000, 0.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0);
- SetObjectMaterial(CreateObject(18981, 25.00000, 25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0), 0, 18646, "matcolours", "yellow");
- SetObjectMaterial(CreateObject(18981, -25.00000, 25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0), 0, 18646, "matcolours", "yellow");
- SetObjectMaterial(CreateObject(18981, 25.00000, -25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0), 0, 18646, "matcolours", "yellow");
- SetObjectMaterial(CreateObject(18981, -25.00000, -25.00000, 5.00000, 0.00000, 90.00000, 0.00000, 1000.0), 0, 18646, "matcolours", "yellow");
- rotob = CreateObject(1946, 0.00000, 0.00000, 52.00000, 0.00000, 0.00000, 0.00000, 1000.0);
- AttachObjectToObject(CreateObject(19130, 0.00000, 0.00000, 52.00000, 0.00000, 0.00000, 0.00000, 1000.0), rotob, 0.0, 0.5, 0.0, 0.0, 90.0, -90.0, true);
- angleob = CreateObject(18644, 0.00000, 0.00000, 50.00000, 90-0.00000, 0.00000, 0.00000, 1000.0);
- AttachObjectToObject(CreateObject(19130, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 0.00000, 1000.0), angleob, 0.0, 0.5, 0.0, 90.0, 0.0, 0.0, true);
- TDEditor_TD = TextDrawCreate(500.000000, 355.000000, "Initial_speed:_50~n~Rotation:_90~n~Angle:_30.0~n~Gravity:_9.8");
- TextDrawLetterSize(TDEditor_TD, 0.400000, 1.600000);
- TextDrawTextSize(TDEditor_TD, 650.000000, 0.000000);
- TextDrawAlignment(TDEditor_TD, 1);
- TextDrawColor(TDEditor_TD, -1);
- TextDrawUseBox(TDEditor_TD, 1);
- TextDrawBoxColor(TDEditor_TD, 255);
- TextDrawSetShadow(TDEditor_TD, 0);
- TextDrawSetOutline(TDEditor_TD, 0);
- TextDrawBackgroundColor(TDEditor_TD, 255);
- TextDrawFont(TDEditor_TD, 1);
- TextDrawSetProportional(TDEditor_TD, 1);
- TextDrawSetShadow(TDEditor_TD, 0);
- return 1;
- }
- public OnFilterScriptExit()
- {
- KillTimer(st);
- DestroyObject(ob);
- DestroyObject(ob+1);
- DestroyObject(ob+2);
- DestroyObject(ob+3);
- DestroyObject(ob+4);
- DestroyObject(ob+5);
- DestroyObject(ob+6);
- DestroyObject(ob+7);
- DestroyObject(ob+8);
- DestroyObject(ob+9);
- DestroyObject(ob+10);
- DestroyObject(ob+11);
- DestroyObject(ob+12);
- DestroyObject(rotob);
- DestroyObject(rotob+1);
- DestroyObject(angleob);
- DestroyObject(angleob+1);
- TextDrawDestroy(TDEditor_TD);
- return 1;
- }
- forward Update();
- public Update()
- {
- /*
- https://i.gyazo.com/b54795fc07cfa761bb7e1e084143ed76.png
- XY = X0+V0X*t
- Z = Y0+V0Y*T-(gravity/2)*t^2
- */
- new Float:X, Float:Y, Float:Z;
- GetObjectPos(ob, X, Y, Z);
- if(Z <= 5.8)
- {
- KillTimer(st);
- return 1;
- }
- new Float:t = (GetTickCount() - count)*0.001; //MILISECONDS TO SECOUND
- X = (INITIAL_X+(VelX*t))*floatsin(rotation, degrees);
- Y = (INITIAL_Y+(VelX*t))*floatcos(rotation, degrees);
- Z = INITIAL_Z+(VelY*t)+((-gravity/2)*floatpower(t, 2));
- SetObjectPos(ob, X, Y, Z);
- /* MoveObject(ob, (Vel*t), Y, (50+(-4.9*floatpower(t, 2))), ((gravity*t))); */
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- new Keys,ud,lr;
- GetPlayerKeys(playerid,Keys,ud,lr);
- if(Keys & KEY_WALK) //ANGLE
- {
- if(lr == KEY_LEFT)
- {
- angle -= 1.0;
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- }
- else if(lr == KEY_RIGHT)
- {
- angle += 1.0;
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- }
- return 1;
- }
- if(Keys & KEY_FIRE) //ROTATION
- {
- if(lr == KEY_LEFT)
- {
- rotation -= 3.0;
- SetObjectRot(rotob, 0.0, 0.0, -rotation);
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- }
- else if(lr == KEY_RIGHT)
- {
- rotation += 3.0;
- SetObjectRot(rotob, 0.0, 0.0, -rotation);
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- }
- return 1;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- TextDrawShowForPlayer(playerid, TDEditor_TD);
- UpdateTextDraw();
- return 1;
- }
- CMD:go(playerid, params[])
- {
- VelX = Vel*floatsin(angle, degrees);
- VelY = Vel*floatcos(angle, degrees);
- count = GetTickCount();
- st = SetTimer("Update", 10, 1);
- return 1;
- }
- CMD:restart(playerid, params[])
- {
- KillTimer(st);
- SetObjectPos(ob, INITIAL_X, INITIAL_Y, INITIAL_Z);
- return 1;
- }
- CMD:rotation(playerid, params[])
- {
- if(sscanf(params, "f", rotation)) return SendClientMessage(playerid, -1, "{996600}ERROR: /rotation [Float: rotation]");
- SetObjectRot(rotob, 0.0, 0.0, -rotation);
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- return 1;
- }
- CMD:angle(playerid, params[])
- {
- if(sscanf(params, "f", angle)) return SendClientMessage(playerid, -1, "{996600}ERROR: /rotation [Float: rotation]");
- SetObjectRot(angleob, 90-angle, 0.0, -rotation);
- UpdateTextDraw();
- return 1;
- }
- CMD:speed(playerid, params[])
- {
- if(sscanf(params, "f", Vel)) return SendClientMessage(playerid, -1, "{996600}ERROR: /speed [Float: initial speed]");
- VelX = Vel*floatsin(angle, degrees);
- VelY = Vel*floatcos(angle, degrees);
- UpdateTextDraw();
- return 1;
- }
- CMD:gravity(playerid, params[])
- {
- if(sscanf(params, "f", gravity)) return SendClientMessage(playerid, -1, "{996600}ERROR: /gravity [Float: gravity (9.8 earth)]");
- UpdateTextDraw();
- return 1;
- }
- UpdateTextDraw()
- {
- new str[128];
- format(str, sizeof(str), "Initial_speed:_%.1f~n~Rotation:_%.1f~n~Angle:_%.1f~n~Gravity:_%.1f", Vel, rotation, angle, gravity);
- TextDrawSetString(TDEditor_TD, str);
- }
- //Experimental FS by adri1
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement