Skip to content

Commit

Permalink
Merge pull request #117 from InterSstellar/master
Browse files Browse the repository at this point in the history
Switch To Streamer v2.9.4 And Some Bug Fixes
  • Loading branch information
Crayder authored Jul 19, 2020
2 parents 734b1aa + 5fca7be commit 0d6ed97
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 529 deletions.
Binary file modified filterscripts/tstudio.amx
Binary file not shown.
9 changes: 6 additions & 3 deletions filterscripts/tstudio.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ Change Log:
// Maximum text length
#define MAX_TEXT_LENGTH 129

// Max Groups
#define MAX_GROUPS 201


// 3D Text drawdistance
new Float:TEXT3D_DRAW_DIST = 100.0;
Expand Down Expand Up @@ -574,14 +577,14 @@ new bool:MapOpen;
#include "tstudio\texviewer.pwn"

// ===== Restriction Variables =====
new Iterator:Restriction[51]<MAX_PLAYERS>, bool:gRestricted[51] = {false, ...};
new Iterator:Restriction[MAX_GROUPS]<MAX_PLAYERS>, bool:gRestricted[MAX_GROUPS] = {false, ...};

// playerid, object index (must be 0 or more than 50, if not it must be in a group with no restrictions, if not then the restriction must allow this player)
#define CanSelectObject(%0,%1) \
(!(0 <= %1 < MAX_TEXTURE_OBJECTS) || (!gRestricted[ObjectData[%1][oGroup]] || !(0 < ObjectData[%1][oGroup] <= 50) || !Iter_Count(Restriction[ObjectData[%1][oGroup]]) || Iter_Contains(Restriction[ObjectData[%1][oGroup]], playerid) || IsPlayerAdmin(playerid)))
(!(0 <= %1 < MAX_TEXTURE_OBJECTS) || (!gRestricted[ObjectData[%1][oGroup]] || !(0 < ObjectData[%1][oGroup] < MAX_GROUPS) || !Iter_Count(Restriction[ObjectData[%1][oGroup]]) || Iter_Contains(Restriction[ObjectData[%1][oGroup]], playerid) || IsPlayerAdmin(playerid)))
// playerid, group index (it must be a group with no restrictions, if not then the restriction must allow this player)
#define CanSelectGroup(%0,%1) \
(!(0 < %1 <= 50) || (!gRestricted[%1] || !Iter_Count(Restriction[%1]) || Iter_Contains(Restriction[%1], playerid) || IsPlayerAdmin(playerid)))
(!(0 < %1 < MAX_GROUPS) || (!gRestricted[%1] || !Iter_Count(Restriction[%1]) || Iter_Contains(Restriction[%1], playerid) || IsPlayerAdmin(playerid)))
//not in this ? then safely test these
// ===== Not a very good modular technique... =====

Expand Down
12 changes: 11 additions & 1 deletion filterscripts/tstudio/cmdbuffer.pwn
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
#define MAX_COMMAND_BUFFER (20)
new CommandBuffer[MAX_PLAYERS][MAX_COMMAND_BUFFER][128];
Expand All @@ -8,21 +9,26 @@ new CommandBuffer[MAX_PLAYERS][MAX_COMMAND_BUFFER][128];
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
new bool:HoldKeyPressed;
*/
OnPlayerKeyStateChangeCMD(playerid,newkeys,oldkeys)
{
#pragma unused playerid, newkeys, oldkeys
/*
if(HoldKeyPressed && PRESSED(KEY_CROUCH) && !isnull(CommandBuffer[playerid][0]))
Command_ReProcess(playerid, sprintf("/%s", CommandBuffer[playerid][0]), 0); //BroadcastCommand(playerid, CommandBuffer[playerid][0]);
if(PRESSED(KEY_WALK))
HoldKeyPressed = true;
else if(RELEASED(KEY_WALK))
HoldKeyPressed = false;
*/

return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
/*
//print(cmdtext);
// Make every slot, start from slot 2, take the data from the slot before
Expand All @@ -36,11 +42,12 @@ public OnPlayerCommandText(playerid, cmdtext[])
// Insert the command and it's parameters into the buffer
//CommandBuffer[playerid][0][0] = EOS;
format(CommandBuffer[playerid][0], 128, "%s", cmdtext);
strtrim(CommandBuffer[playerid][0], "/");
*/

#if defined CB_OnPlayerCommandText
CB_OnPlayerCommandText(playerid, cmdtext);
#endif

return 0;
}
#if defined _ALS_OnPlayerCommandText
Expand All @@ -55,13 +62,16 @@ public OnPlayerCommandText(playerid, cmdtext[])

public OnPlayerConnect(playerid)
{
/*
// Reset the player's buffer
new tmpCommandBuffer[MAX_COMMAND_BUFFER][128];
CommandBuffer[playerid] = tmpCommandBuffer;
*/

#if defined CB_OnPlayerConnect
CB_OnPlayerConnect(playerid);
#endif

return 1;
}
#if defined _ALS_OnPlayerConnect
Expand Down
37 changes: 29 additions & 8 deletions filterscripts/tstudio/flymode.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@ public OnPlayerConnect(playerid)

//--------------------------------------------------

public OnPlayerDisconnect(playerid, reason)
{
if(noclipdata[playerid][cameramode] == CAMERA_MODE_FLY) CancelFlyMode(playerid);

#if defined FM_OnPlayerDisconnect
FM_OnPlayerDisconnect(playerid, reason);
#endif
return 1;
}
#if defined _ALS_OnPlayerDisconnect
#undef OnPlayerDisconnect
#else
#define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect FM_OnPlayerDisconnect
#if defined FM_OnPlayerDisconnect
forward FM_OnPlayerDisconnect(playerid, reason);
#endif

//--------------------------------------------------

YCMD:flymode(playerid, arg[], help)
{
if(help)
Expand Down Expand Up @@ -209,7 +230,7 @@ public OnPlayerUpdate(playerid)
{
if((noclipdata[playerid][udold] != 0 || noclipdata[playerid][lrold] != 0) && ud == 0 && lr == 0)
{ // All keys have been released, stop the object the camera is attached to and reset the acceleration multiplier
StopPlayerObject(playerid, noclipdata[playerid][flyobject]);
StopDynamicObject(noclipdata[playerid][flyobject]);
noclipdata[playerid][mode] = 0;
noclipdata[playerid][accelmul] = 0.0;
}
Expand Down Expand Up @@ -276,7 +297,7 @@ tsfunc MoveCamera(playerid)
{
new Float:FV[3], Float:CP[3];
//GetPlayerCameraPos(playerid, CP[0], CP[1], CP[2]); // Cameras position in space
GetPlayerObjectPos(playerid, noclipdata[playerid][flyobject], CP[0], CP[1], CP[2]); // Cameras position in space
GetDynamicObjectPos(noclipdata[playerid][flyobject], CP[0], CP[1], CP[2]); // Cameras position in space
GetPlayerCameraFrontVector(playerid, FV[0], FV[1], FV[2]); // Where the camera is looking at

// Increases the acceleration multiplier the longer the key is held
Expand All @@ -288,7 +309,7 @@ tsfunc MoveCamera(playerid)
// Calculate the cameras next position based on their current position and the direction their camera is facing
new Float:X, Float:Y, Float:Z;
GetNextCameraPosition(noclipdata[playerid][mode], CP, FV, X, Y, Z);
MovePlayerObject(playerid, noclipdata[playerid][flyobject], X, Y, Z, speed);
MoveDynamicObject(noclipdata[playerid][flyobject], X, Y, Z, speed, 0.0, 0.0, 0.0);

//SendClientMessage(playerid, -1, sprintf("(%0.1f, %0.1f, %0.1f) - (%0.1f, %0.1f, %0.1f) - (%0.1f, %0.1f, %0.1f)", CP[0], CP[1], CP[2], FV[0], FV[1], FV[2], X, Y, Z));

Expand All @@ -301,7 +322,7 @@ tsfunc SetFlyModePos(playerid, Float:x, Float:y, Float:z)
{
if(FlyMode[playerid])
{
SetPlayerObjectPos(playerid, noclipdata[playerid][flyobject], x, y, z);
SetDynamicObjectPos(noclipdata[playerid][flyobject], x, y, z);
noclipdata[playerid][lastmove] = GetTickCount();
return 1;
}
Expand All @@ -311,7 +332,7 @@ tsfunc GetFlyModePos(playerid, &Float:x, &Float:y, &Float:z)
{
if(FlyMode[playerid])
{
GetPlayerObjectPos(playerid, noclipdata[playerid][flyobject], x, y, z);
GetDynamicObjectPos(noclipdata[playerid][flyobject], x, y, z);
return 1;
}
return 0;
Expand Down Expand Up @@ -391,7 +412,7 @@ tsfunc CancelFlyMode(playerid)
CancelEdit(playerid);
TogglePlayerSpectating(playerid, false);

DestroyPlayerObject(playerid, noclipdata[playerid][flyobject]);
DestroyDynamicObject(noclipdata[playerid][flyobject]);
noclipdata[playerid][cameramode] = CAMERA_MODE_NONE;
return 1;
}
Expand All @@ -406,12 +427,12 @@ tsfunc StartFlyMode(playerid)
// Create an invisible object for the players camera to be attached to
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
noclipdata[playerid][flyobject] = CreatePlayerObject(playerid, 19300, X, Y, Z, 0.0, 0.0, 0.0);
noclipdata[playerid][flyobject] = CreateDynamicObject(19300, X, Y, Z, 0.0, 0.0, 0.0, .playerid = playerid, .streamdistance = 300.0, .drawdistance = 300.0);

// Place the player in spectating mode so objects will be streamed based on camera location
TogglePlayerSpectating(playerid, true);
// Attach the players camera to the created object
AttachCameraToPlayerObject(playerid, noclipdata[playerid][flyobject]);
AttachCameraToDynamicObject(playerid, noclipdata[playerid][flyobject]);

FlyMode[playerid] = true;
noclipdata[playerid][cameramode] = CAMERA_MODE_FLY;
Expand Down
3 changes: 3 additions & 0 deletions filterscripts/tstudio/groups.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ YCMD:setgroup(playerid, arg[], help)
MapOpenCheck();
NoEditingMode(playerid);

if (!(0 <= strval(arg) < MAX_GROUPS))
return SendClientMessage(playerid, STEALTH_YELLOW, sprintf("The group id must be from 0 to %d", MAX_GROUPS - 1));

new groupid = strval(arg);

new time = GetTickCount();
Expand Down
2 changes: 1 addition & 1 deletion filterscripts/tstudio/helpcmd.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ new Commands[][COMMAND_INFO] = {
{7, 8, "avmirror"},

{8, 0, "runbind"},
{8, 0, "makebind"},
//{8, 0, "makebind"},
{8, 0, "bindeditor"},

{9, 0, "hidetext3d"},
Expand Down
5 changes: 3 additions & 2 deletions filterscripts/tstudio/menugui.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ YCMD:runbind(playerid, arg[], help)
return 1;
}

/*
YCMD:makebind(playerid, arg[], help)
{
if(help)
Expand All @@ -1642,7 +1643,7 @@ YCMD:makebind(playerid, arg[], help)
for(new x; x < range; x++) {
//CommandBindData[index][x] = CommandBuffer[playerid][range - 1 - x];
format(CommandBindData[index][x], 128, "/%s", CommandBuffer[playerid][range - 1 - x]);
format(CommandBindData[index][x], 128, "%s", CommandBuffer[playerid][range - 1 - x]);
printf("%i: %s", x, CommandBindData[index][x]);
}
Expand All @@ -1653,7 +1654,7 @@ YCMD:makebind(playerid, arg[], help)
return 1;
}

*/

YCMD:bindeditor(playerid, arg[], help)
{
Expand Down
8 changes: 4 additions & 4 deletions filterscripts/tstudio/restrict.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ YCMD:restrict(playerid, arg[], help)
return 1;
}

if(!(0 < groupid <= 50))
return SendClientMessage(playerid, STEALTH_YELLOW, "You can only restrict groups 1-50");
if(!(0 < groupid < MAX_GROUPS))
return SendClientMessage(playerid, STEALTH_YELLOW, sprintf("You can only restrict groups 1-%d", MAX_GROUPS - 1));

Iter_Clear(Restriction[groupid]);

Expand Down Expand Up @@ -135,8 +135,8 @@ YCMD:unrestrict(playerid, arg[], help)
return 1;
}

if(!(0 < groupid <= 50))
return SendClientMessage(playerid, STEALTH_YELLOW, "You can only restrict groups 1-50");
if(!(0 < groupid < MAX_GROUPS))
return SendClientMessage(playerid, STEALTH_YELLOW, sprintf("You can only restrict groups 1-%d", MAX_GROUPS - 1));

Iter_Clear(Restriction[groupid]);
gRestricted[groupid] = false;
Expand Down
23 changes: 21 additions & 2 deletions filterscripts/tstudio/tsmain.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public OnFilterScriptInit()
sqlite_LoadBindString();

ResetSettings();

Streamer_ToggleErrorCallback(1); // Enable Streammer Error Callback

#if defined AddSimpleModel // DL-SUPPORT
Streamer_SetVisibleItems(STREAMER_TYPE_OBJECT, 1500);
Expand Down Expand Up @@ -138,6 +140,9 @@ OnPlayerKeyStateChangeOEdit(playerid,newkeys,oldkeys)
return 0;
}

// player finished editing an object; Fix For new streamer version
public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) return 0;

// player finished editing an object
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
Expand Down Expand Up @@ -219,7 +224,7 @@ public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y,
#if defined MA_OnPlayerEditDynamicObject
MA_OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
#endif
return 1;
return 0;
}
#if defined _ALS_OnPlayerEditDynamicObject
#undef OnPlayerEditDynamicObject
Expand All @@ -231,6 +236,11 @@ public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y,
forward MA_OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
#endif



// Player clicked a dynamic object; Fix For new streamer version
public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ) return 0;

// Player clicked a dynamic object
public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y, Float:z)
{
Expand Down Expand Up @@ -281,7 +291,13 @@ public OnPlayerSelectDynamicObject(playerid, objectid, modelid, Float:x, Float:y
}
}
}
return 1;
return 0;
}

// Streamer Error Log
public Streamer_OnPluginError(const error[])
{
printf("Streamer Plugin Error: %s", error);
}

// Player clicked textdraw
Expand Down Expand Up @@ -3642,6 +3658,9 @@ YCMD:ogroup(playerid, arg[], help)

NoEditingMode(playerid);

if (!(0 <= strval(arg) < MAX_GROUPS))
return SendClientMessage(playerid, STEALTH_YELLOW, sprintf("The group id must be from 0 to %d", MAX_GROUPS - 1));

new index = CurrObject[playerid];

SaveUndoInfo(index, UNDO_TYPE_EDIT);
Expand Down
Loading

0 comments on commit 0d6ed97

Please sign in to comment.