Help please
#1

Problem with yom_buttons. When I run my server without compiling it. The samp-server gives me the following:

Код:
--------------------------------------------

  Loading filterscript 'yom_buttons.amx'...
*** Streamer Plugin: Warning: Obsolete or invalid native "Streamer_RegisterInter
face" found (script might need to be recompiled with the latest include file)
*** Streamer Plugin: Warning: Obsolete or invalid native "Streamer_AddPlayer" fo
und (script might need to be recompiled with the latest include file)
*** Streamer Plugin: Warning: Obsolete or invalid native "Streamer_RemovePlayer"
 found (script might need to be recompiled with the latest include file)
*** Streamer Plugin: Warning: Obsolete or invalid native "Streamer_VerifyPickup"
 found (script might need to be recompiled with the latest include file)
*** Streamer Plugin: Warning: Obsolete or invalid native "Streamer_VerifyCheckpo
int" found (script might need to be recompiled with the latest include file)
*** Streamer Plugin: Warning: Include file version (unknown version) does not ma
tch plugin version (0x26105) (script might need to be recompiled with the latest
 include file)
  Loading filterscript 'vactions.amx'...
  Loading filterscript 'robbery.amx'...
  Loaded 5 filterscripts.

Script[gamemodes/lgrp.amx]: Run time error 19: "File or function is not found"
Number of vehicle models: 0
It was working well and the buttons were loaded but suddenly that errors came after 5 days maybe

When I tried to re-compile I got this:

Код:
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(26) : error 033: array must be indexed (variable "glob1C")
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(28) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(29) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(30) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(31) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(32) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(33) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(34) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(35) : error 033: array must be indexed (variable "glob1C")
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(36) : error 017: undefined symbol "Streamer_RegisterInterface"
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(38) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(40) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(47) : error 033: array must be indexed (variable "glob1C")
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(49) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(50) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(51) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(52) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(53) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(54) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(55) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(56) : error 033: array must be indexed (variable "glob1C")
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(57) : error 017: undefined symbol "Streamer_RegisterInterface"
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(59) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(61) : error 035: argument type mismatch (argument 1)
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(70) : error 017: undefined symbol "Streamer_AddPlayer"
D:\Users\Sobhy\Desktop\BGRP\filterscripts\yom_buttons.pwn(74) : error 035: argument type mismatch (argument 1)

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
The script:

Код:
#include <a_samp>
#include <core>
#include <float>

new glob0;

new glob4;

new glob8;

new globC;

new glob10;

new glob14;

new glob18;

new glob1C[698];

new globB04[201][505];


public OnFilterScriptInit()
{
	if(!glob1C)
	{
		glob0 = funcidx(32) != -1;
		glob4 = funcidx(132) != -1;
		glob8 = funcidx(244) != -1;
		globC = funcidx(364) != -1;
		glob10 = funcidx(464) != -1;
		glob14 = funcidx(564) != -1;
		glob18 = funcidx(680) != -1;
		glob1C = 1;
		Streamer_RegisterInterface();
	}
	if(-1 != funcidx(796))
	{
		return CallLocalFunction(908, 1020);
	}
	return 1;
}

public OnGameModeInit()
{
	if(!glob1C)
	{
		glob0 = funcidx(1024) != -1;
		glob4 = funcidx(1124) != -1;
		glob8 = funcidx(1236) != -1;
		globC = funcidx(1356) != -1;
		glob10 = funcidx(1456) != -1;
		glob14 = funcidx(1556) != -1;
		glob18 = funcidx(1672) != -1;
		glob1C = 1;
		Streamer_RegisterInterface();
	}
	if(-1 != funcidx(1788))
	{
		return CallLocalFunction(1884, 1980);
	}
	return 1;
}

public OnPlayerConnect(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_AddPlayer(playerid);
	}
	if(glob0)
	{
		return CallLocalFunction(1984, 2084, playerid);
	}
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_RemovePlayer(playerid);
	}
	if(glob4)
	{
		return CallLocalFunction(2092, 2204, playerid, reason);
	}
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_VerifyPickup(playerid, pickupid);
	}
	if(glob8)
	{
		return CallLocalFunction(2216, 2336, playerid, pickupid);
	}
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_VerifyCheckpoint(playerid, 2, 0);
	}
	if(globC)
	{
		return CallLocalFunction(2348, 2448, playerid);
	}
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_VerifyCheckpoint(playerid, 2, 1);
	}
	if(glob10)
	{
		return CallLocalFunction(2456, 2556, playerid);
	}
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_VerifyCheckpoint(playerid, 3, 0);
	}
	if(glob14)
	{
		return CallLocalFunction(2564, 2680, playerid);
	}
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	if(!IsPlayerNPC(playerid))
	{
		Streamer_VerifyCheckpoint(playerid, 3, 1);
	}
	if(glob18)
	{
		return CallLocalFunction(2688, 2804, playerid);
	}
	return 1;
}

public Streamer_PublicFunction()
{
	new Float:var0 = 0.0;
	CreatePickup(0, 0, 0.0, 0.0, 0.0, 0);
	CreatePlayer3DTextLabel(0, 2812, 0, 0, 0, 0, 0, 0, 0, 0);
	CreatePlayerObject(0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
	DeletePlayer3DTextLabel(0, 0);
	DestroyPickup(0);
	DestroyPlayerObject(0, 0);
	DisablePlayerCheckpoint(0);
	DisablePlayerRaceCheckpoint(0);
	GetPlayerInterior(0);
	GetPlayerPos(0, var0, var0, var0);
	GetPlayerState(0);
	GetPlayerVirtualWorld(0);
	GetVehiclePos(0, var0, var0, var0);
	MovePlayerObject(0, 0, 0.0, 0.0, 0.0, 0.0);
	RemovePlayerMapIcon(0, 0);
	SetPlayerCheckpoint(0, 0.0, 0.0, 0.0, 0.0);
	SetPlayerMapIcon(0, 0, 0.0, 0.0, 0.0, 0, 0x00000000, 0);
	SetPlayerObjectPos(0, 0, 0.0, 0.0, 0.0);
	SetPlayerObjectRot(0, 0, 0.0, 0.0, 0.0);
	SetPlayerRaceCheckpoint(0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
	StopPlayerObject(0, 0);
	UpdatePlayer3DTextLabelText(0, 0, 0, 2816);
	return 1;
}

Float:functionFDC(Float:arg0, Float:arg1, arg2)
{
	new Float:var0[4];
	for(new var1 = 0; var1 < 3; var1++)
	{
		var0[var1] = arg0[var1] - arg1[var1];
		var0[var1] = var0[var1] * var0[var1];
	}
	var0[3] = var0[0] + var0[1] + var0[2];
	return (arg2 ? floatsqroot(var0[3]) : var0[3]);
}

Float:function1250(Float:arg0, Float:arg1)
{
	new var0[2], var1[2], Float:var2 = 0.0;
	for(new var3 = 0; var3 < 2; var3++)
	{
		var0[var3] = arg0[var3] < arg1[var3];
		var1[var3] = (var0[var3] ? arg1[var3] - arg0[var3] : arg0[var3] - arg1[var3]);
	}
	var2 = atan2(var1[1], var1[0]);
	var2 = (var0[0] ? 270.0 + var2 : 90.0 - var2);
	var2 = (var0[1] ? var2 : 180.0 - var2);
	return var2;
}

function15C0(Float:arg0, &Float:arg1)
{
	new var0 = 4294967295, Float:var1 = 100000.0;
	for(new var2 = 1, new var3, new var4 = 0, FS_GetHighestButtonID(), var3 = FS_GetHighestButtonID(); var2 <= var3; var2++)
	{
		if(globB04[var2][0])
		{
			arg1 = functionFDC(arg0, globB04[var2], 1);
			if(arg1 < var1)
			{
				var1 = arg1;
				var0 = var2;
			}
		}
	}
	arg1 = var1;
	return var0;
}

public FS_CreateButton(arg0, arg1, arg2, arg3, arg4)
{
	new var0 = 0;
	for(var0 = 1; var0 <= 200; var0++)
	{
		if(!globB04[var0][0])
		{
		}
		else
		{
		}
	}
	globB04[var0][506] = CreateDynamicObject(2886, arg0, arg1, arg2, 0, 0, arg3, arg4, 4294967295, 4294967295, 1128792064);
	globB04[var0][502] = arg0;
	globB04[var0][503] = arg1;
	globB04[var0][504] = arg2;
	globB04[var0][505] = arg3;
	globB04[var0][1] = 0;
	globB04[var0][0] = 1;
	for(new var1 = 0; var1 < 500; var1++)
	{
		globB04[var0][var1] = 1;
	}
	return var0;
}

public FS_DestroyButton(arg0)
{
	if(FS_IsValidButton(arg0))
	{
		CallRemoteFunction(411252, 411324, arg0);
		globB04[arg0][0] = 0;
		DestroyDynamicObject(globB04[arg0][506]);
	}
	return 0;
}

public FS_SetButtonPos(arg0, arg1, arg2, arg3, arg4)
{
	if(FS_IsValidButton(arg0))
	{
		new var0 = globB04[arg0][506];
		SetDynamicObjectPos(var0, arg1, arg2, arg3);
		SetDynamicObjectRot(var0, 0, 0, arg4);
		globB04[arg0][502] = arg1;
		globB04[arg0][503] = arg2;
		globB04[arg0][504] = arg3;
		globB04[arg0][505] = arg4;
	}
	return 0;
}

public FS_MoveButton(arg0, arg1, arg2, arg3, arg4)
{
	if(FS_IsValidButton(arg0))
	{
		MoveDynamicObject(globB04[arg0][506], arg1, arg2, arg3, arg4);
		globB04[arg0][1] = 1;
		globB04[arg0][502] = 1203982323;
		globB04[arg0][503] = 1203982323;
		globB04[arg0][504] = 1203982323;
	}
	return 0;
}

public FS_StopButton(arg0)
{
	if(FS_IsValidButton(arg0))
	{
		StopDynamicObject(globB04[arg0][506]);
	}
	return 0;
}

public FS_IsValidButton(arg0)
{
	return 0;
}

public FS_GetHighestButtonID()
{
	if(globB04[arg0][0])
	{
	}
	if(arg0 <= 200)
	{
	}
	if(0 < --var0)
	{
		if(globB04[var0][0])
		{
			return var0;
		}
	}
	else
	{
	}
	return -1;
}

public FS_GetButtonObjectID(arg0)
{
	return (FS_IsValidButton(arg0) ? globB04[arg0][506] : 65535);
}

public FS_GetObjectButtonID(arg0)
{
	for(new var0 = 1, new var1, new var2 = 0, FS_GetHighestButtonID(), var1 = FS_GetHighestButtonID(); var0 <= var1; var0++)
	{
		if(globB04[var0][0] && globB04[var0][506] == arg0)
		{
			return var0;
		}
	}
	return -1;
}

public FS_PrintButtonsInfos()
{
	print("\n ЪДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДї\n і                   Buttons Informations                  і\n ГДДДДДДДДВДДДДДДДДВДДДДДДДДДВДДДДДДДДДВДДДДДДДДДВДДДДДДДДДґ\n іButtonIDіObjectIDі    X    і    Y    і    Z    і    A    і\n ГДДДДДДДДЕДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДґ");
	for(new var0 = 1; var0 <= 200; var0++)
	{
		if(globB04[var0][0])
		{
			printf(" і%8dі%8dі%6.2fі%6.2fі%6.2fі%6.2fі", var0, globB04[var0][506], globB04[var0][502], globB04[var0][503], globB04[var0][504], globB04[var0][505]);
		}
	}
	print(" АДДДДДДДДБДДДДДДДДБДДДДДДДДДБДДДДДДДДДБДДДДДДДДДБДДДДДДДДДЩ\n");
	return 0;
}

public Float:FS_GetDistanceToButton(arg0, arg1, arg2, arg3)
{
	if(FS_IsValidButton(arg0))
	{
		new Float:var0[3];
		var0[0] = arg1;
		var0[1] = arg2;
		var0[2] = arg3;
		return functionFDC(var0, globB04[arg0], 1);
	}
	return -1.0;
}

public FS_TeleportPlayerToButton(playerid, arg1)
{
	if(FS_IsValidButton(arg1) && !globB04[arg1][1])
	{
		new var0 = globB04[arg1][505];
		SetPlayerPos(playerid, globB04[arg1][502] - (0.6499 * floatsin(-var0, 1)), globB04[arg1][503] - (0.6499 * floatcos(-var0, 1)), globB04[arg1][504] - 0.6299);
		SetPlayerFacingAngle(playerid, -var0);
		SetCameraBehindPlayer(playerid);
	}
	return 0;
}

public FS_ToggleButtonEnabledForPlayer(arg0, arg1, arg2)
{
	if(FS_IsValidButton(arg1))
	{
		globB04[arg1][arg0] = arg2;
	}
	return 0;
}

public FS_ToggleButtonEnabled(arg0, arg1)
{
	if(FS_IsValidButton(arg0))
	{
		new var0 = 0;
		while(++var0 < 500)
		{
			globB04[arg0][var0] = arg1;
		}
	}
	return 0;
}

public OnPlayerPressButton_Delay(playerid, arg1)
{
	PlayerPlaySound(playerid, 1083, 0.0, 0.0, 0.0);
	CallRemoteFunction(412944, 413024, playerid, arg1);
	return 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(GetPlayerState(playerid) == 1)
	{
		if(newkeys & 16)
		{
			new Float:var0 = 0.0, Float:var1 = 0.0, Float:var2[3], var3 = 0;
			GetPlayerPos(playerid, var2, var2, var2);
			var3 = function15C0(var2, var0);
			if(-1 != var3 && globB04[var3][playerid] && var0 <= 1.2999)
			{
				var1 = function1250(var2, globB04[var3]);
				SetPlayerFacingAngle(playerid, var1);
				SetPlayerPos(playerid, globB04[var3][502] - (0.6499 * floatsin(-var1, 1)), globB04[var3][503] - (0.6499 * floatcos(-var1, 1)), globB04[var3][504] - 0.6299);
				ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0, 0);
				SetTimerEx("OnPlayerPressButton_Delay", 500, false, "ii", playerid, var3);
			}
		}
	}
	return 0;
}

public OnObjectMoved(objectid)
{
	new var0 = FS_GetObjectButtonID(objectid);
	if(-1 != var0)
	{
		new Float:var1[3];
		GetObjectPos(objectid, var1, var1, var1);
		globB04[var0][502] = var1[0];
		globB04[var0][503] = var1[1];
		globB04[var0][504] = var1[2];
		globB04[var0][1] = 0;
		CallRemoteFunction(413236, 413292, var0);
	}
	return 0;
}

public Streamer_OnPlayerConnect(playerid)
{
	ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0, 0);
	return 0;
}

public Streamer_OnGameModeInit()
{
	return 1;
}

public OnGameModeExit()
{
	for(new var0 = 1; var0 <= 200; var0++)
	{
		if(globB04[var0][0])
		{
			FS_DestroyButton(var0);
		}
	}
	return 1;
}
Please help me
Reply
#2

I don't know actually, but I think the code you posted isn't yom_buttons (or maybe it's an old version, I don't know). Anyway, I had this code which I was using in the past and I think this is the correct yom_buttons.
pawn Код:
/*##############################################################################


                    #########################################
                    #                                       #
                    #     BUTTONS - FILTERSCRIPT BY YOM     #
                    #               v1.3 BETA               #
                    #       Steal my work and die >:D       #
                    #                                       #
                    #########################################


- Informations about this file:
===============================

    -   You must #include <yom_buttons> in the scripts you want to use buttons




- Copyright:
============

    -   Yom's Scripts Factory © ®.
    -   You can use this script and distribute it but,
    -   You WILL NOT sell it or tell it's your own work.



- Versions changes:
===================

    -   1.0 :   Initial release.
   
    -   1.1 :   Small tweaks here and there.
   
    -   1.2 :   Removed: rX and rY parameters (was useless, for me anyway)
                Changed: rZ parameter is now named Angle
                Changed: CreateButton now returns the objectid, not the buttonid.
                Added: Sets the pos of the player, so he press exactly on the button.
               
    -   1.3 :   Changed again: CreateButton returns the buttonid (from 1 to MAX_BUTTONS).
                Changed: Player can press the button from any angle
                Added: more or less useful functions for use in your scripts
                Added: sound
                Added: button placer (if debug enabled, type /button)
                THIS IS A BETA VERSION, PLEASE DON'T BE A BASTARD, AND REPORT BUGS/PROBLEMS!


##############################################################################*/











/*################################ CONFIGURATION #############################*/

//max buttons that can be created.
#define MAX_BUTTONS  200


//this is the distance max for detecting buttons. If the player is at this
//distance, or less, of a button, he will press this button.
#define MAX_DISTANCE    1.3


//this is the object modelid used for buttons.
//i'm asking for nice objects, if you know some that can be used as buttons, tell me!
#define OBJECT          2886


//comment this line to disable the sound, or change the number for another sound
//don't forget that you can do whatever you want in OnPlayerPressButton
#define SOUND           1083


//comment this line to disable debug (recommended once you finished using the
//buttons editor, this will make the script more efficient)
//#define DEBUG

/*############################################################################*/










/*----------------------------------------------------------------------------*/
#include <a_samp>
#include <streamer>

#undef MAX_PLAYERS
#define MAX_PLAYERS 1000

#define INVALID_BUTTON_ID   -1


enum BUTTON_INFOS
{
    bool:Created,
    bool:Moving,
    bool:Usable[MAX_PLAYERS],
    Float:Pos[4],
    ObjectID
}

new ButtonInfo[MAX_BUTTONS+1][BUTTON_INFOS];

#if defined DEBUG

    enum PLAYER_INFOS
    {
        Float:MSpeed,
        SelectedButton,
        TimerID
    }
   
    new PlayerInfo[MAX_PLAYERS][PLAYER_INFOS];
    new String[128];

#endif
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
Float:Distance3D(Float:PointA[], Float:PointB[], bool:sqrt = true)
{
    new Float:Dist[4];
   
    for (new i = 0; i < 3; i++)
    {
        Dist[i] = PointA[i] - PointB[i];
        Dist[i] *= Dist[i];
    }
   
    Dist[3] = Dist[0] + Dist[1] + Dist[2];
   
    return sqrt ? floatsqroot(Dist[3]) : Dist[3];
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
Float:Angle2D(Float:PointA[], Float:PointB[])
{
    new bool:A_LS_B[2], Float:Dist[2], Float:Angle;

    for (new i = 0; i < 2; i++)
    {
        A_LS_B[i] = PointA[i] < PointB[i];
        Dist[i] = A_LS_B[i] ? PointB[i] - PointA[i] : PointA[i] - PointB[i];
    }

    Angle = atan2(Dist[1],Dist[0]);
    Angle = A_LS_B[0] ? 270.0 + Angle : 90.0 - Angle;
    Angle = A_LS_B[1] ? Angle : 180.0 - Angle;

    return Angle;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
GetClosestButton(Float:Point[], &Float:Distance = 0.0)
{
    new Closest = INVALID_BUTTON_ID, Float:Distance2 = 100000.0;

    for (new buttonid = 1, highest = FS_GetHighestButtonID(); buttonid <= highest; buttonid ++)
    {
        if (ButtonInfo[buttonid][Created])
        {
            Distance = Distance3D(Point, ButtonInfo[buttonid][Pos]);

            if (Distance < Distance2)
            {
                Distance2 = Distance;
                Closest = buttonid;
            }
        }
    }

    Distance = Distance2;

    return Closest;
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward FS_CreateButton(Float:X, Float:Y, Float:Z, Float:Angle, VW);
public FS_CreateButton(Float:X, Float:Y, Float:Z, Float:Angle, VW)
{
    new buttonid;
   
    for(buttonid = 1; buttonid <= MAX_BUTTONS; buttonid ++)
        if (!ButtonInfo[buttonid][Created])
            break;

    ButtonInfo[buttonid][ObjectID]  = CreateDynamicObject(OBJECT,X,Y,Z,0.0,0.0,Angle, VW);
    ButtonInfo[buttonid][Pos][0]    = X;
    ButtonInfo[buttonid][Pos][1]    = Y;
    ButtonInfo[buttonid][Pos][2]    = Z;
    ButtonInfo[buttonid][Pos][3]    = Angle;
    ButtonInfo[buttonid][Moving]    = false;
    ButtonInfo[buttonid][Created]   = true;
   
    for (new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
        ButtonInfo[buttonid][Usable][playerid] = true;

    return buttonid;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_DestroyButton(buttonid);
public FS_DestroyButton(buttonid)
{
    if (FS_IsValidButton(buttonid))
    {
        CallRemoteFunction("OnButtonDestroyed", "i", buttonid);
        ButtonInfo[buttonid][Created] = false;
        DestroyDynamicObject(ButtonInfo[buttonid][ObjectID]);
    }
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward FS_SetButtonPos(buttonid, Float:X, Float:Y, Float:Z, Float:Angle);
public FS_SetButtonPos(buttonid, Float:X, Float:Y, Float:Z, Float:Angle)
{
    if (FS_IsValidButton(buttonid))
    {
        new objectid = ButtonInfo[buttonid][ObjectID];
        SetDynamicObjectPos(objectid, X, Y, Z);
        SetDynamicObjectRot(objectid, 0.0, 0.0, Angle);
        ButtonInfo[buttonid][Pos][0] = X;
        ButtonInfo[buttonid][Pos][1] = Y;
        ButtonInfo[buttonid][Pos][2] = Z;
        ButtonInfo[buttonid][Pos][3] = Angle;
    }
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward FS_MoveButton(buttonid, Float:X, Float:Y, Float:Z, Float:Speed);
public FS_MoveButton(buttonid, Float:X, Float:Y, Float:Z, Float:Speed)
{
    if (FS_IsValidButton(buttonid))
    {
        MoveDynamicObject(ButtonInfo[buttonid][ObjectID], X, Y, Z, Speed);
        ButtonInfo[buttonid][Moving] = true;
        ButtonInfo[buttonid][Pos][0] = 99999.9;
        ButtonInfo[buttonid][Pos][1] = 99999.9;
        ButtonInfo[buttonid][Pos][2] = 99999.9;
    }
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_StopButton(buttonid);
public FS_StopButton(buttonid)
{
    if (FS_IsValidButton(buttonid))
        StopDynamicObject(ButtonInfo[buttonid][ObjectID]);
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward bool:FS_IsValidButton(buttonid);
public bool:FS_IsValidButton(buttonid)
{
    return (buttonid <= MAX_BUTTONS && ButtonInfo[buttonid][Created]);
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_GetHighestButtonID();
public FS_GetHighestButtonID()
{
    for (new buttonid = MAX_BUTTONS; buttonid > 0; buttonid --)
        if (ButtonInfo[buttonid][Created])
            return buttonid;

    return INVALID_BUTTON_ID;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_GetButtonObjectID(buttonid);
public FS_GetButtonObjectID(buttonid)
{
    return FS_IsValidButton(buttonid) ? ButtonInfo[buttonid][ObjectID] : INVALID_OBJECT_ID;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_GetObjectButtonID(objectid);
public FS_GetObjectButtonID(objectid)
{
    for (new buttonid = 1, highest = FS_GetHighestButtonID(); buttonid <= highest; buttonid ++)
        if (ButtonInfo[buttonid][Created] && ButtonInfo[buttonid][ObjectID] == objectid)
            return buttonid;

    return INVALID_BUTTON_ID;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_PrintButtonsInfos();
public FS_PrintButtonsInfos()
{
    print
    (
        "\n \
        ЪДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДДї\n \
        і                   Buttons Informations                  і\n \
        ГДДДДДДДДВДДДДДДДДВДДДДДДДДДВДДДДДДДДДВДДДДДДДДДВДДДДДДДДДґ\n \
        іButtonIDіObjectIDі    X    і    Y    і    Z    і    A    і\n \
        ГДДДДДДДДЕДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДЕДДДДДДДДДґ"

    );

    for (new buttonid = 1; buttonid <= MAX_BUTTONS; buttonid ++)
    {
        if (ButtonInfo[buttonid][Created])
        {
            printf
            (
                " і%8dі%8dі%6.2fі%6.2fі%6.2fі%6.2fі",
                buttonid,
                ButtonInfo[buttonid][ObjectID],
                ButtonInfo[buttonid][Pos][0],
                ButtonInfo[buttonid][Pos][1],
                ButtonInfo[buttonid][Pos][2],
                ButtonInfo[buttonid][Pos][3]
            );
        }
    }

    print(" АДДДДДДДДБДДДДДДДДБДДДДДДДДДБДДДДДДДДДБДДДДДДДДДБДДДДДДДДДЩ\n");
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward Float:FS_GetDistanceToButton(buttonid, Float:X, Float:Y, Float:Z);
public Float:FS_GetDistanceToButton(buttonid, Float:X, Float:Y, Float:Z)
{
    if (FS_IsValidButton(buttonid))
    {
        new Float:Point[3];

        Point[0] = X;
        Point[1] = Y;
        Point[2] = Z;

        return Distance3D(Point, ButtonInfo[buttonid][Pos]);
    }

    return -1.0;
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward FS_TeleportPlayerToButton(playerid, buttonid);
public FS_TeleportPlayerToButton(playerid, buttonid)
{
    if (FS_IsValidButton(buttonid) && !ButtonInfo[buttonid][Moving])
    {
        new Float:Angle = ButtonInfo[buttonid][Pos][3];

        SetPlayerPos
        (
            playerid,
            ButtonInfo[buttonid][Pos][0] - (0.65 * floatsin(-Angle,degrees)),
            ButtonInfo[buttonid][Pos][1] - (0.65 * floatcos(-Angle,degrees)),
            ButtonInfo[buttonid][Pos][2] - 0.63
        );

        SetPlayerFacingAngle(playerid, -Angle);
        SetCameraBehindPlayer(playerid);
    }
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_ToggleButtonEnabledForPlayer(playerid, buttonid, bool:enabled);
public FS_ToggleButtonEnabledForPlayer(playerid, buttonid, bool:enabled)
{
    if (FS_IsValidButton(buttonid))
        ButtonInfo[buttonid][Usable][playerid] = enabled;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
forward FS_ToggleButtonEnabled(buttonid, bool:enabled);
public FS_ToggleButtonEnabled(buttonid, bool:enabled)
{
    if (FS_IsValidButton(buttonid))
        for (new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
            ButtonInfo[buttonid][Usable][playerid] = enabled;
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
forward OnPlayerPressButton_Delay(playerid, buttonid);
public OnPlayerPressButton_Delay(playerid, buttonid)
{
    #if defined SOUND
        PlayerPlaySound(playerid, SOUND, 0.0, 0.0, 0.0);
    #endif
    CallRemoteFunction("OnPlayerPressButton", "ii", playerid, buttonid);
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if (newkeys & 16)
        {
            new Float:Distance, Float:Angle, Float:PlayerPos[3], buttonid;

            GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
       
            buttonid = GetClosestButton(PlayerPos, Distance);

            if (buttonid != INVALID_BUTTON_ID && ButtonInfo[buttonid][Usable][playerid] && Distance <= MAX_DISTANCE)
            {
                Angle = Angle2D(PlayerPos, ButtonInfo[buttonid][Pos]);

                SetPlayerFacingAngle(playerid, Angle);

                SetPlayerPos
                (
                    playerid,
                    ButtonInfo[buttonid][Pos][0] - (0.65 * floatsin(-Angle,degrees)),
                    ButtonInfo[buttonid][Pos][1] - (0.65 * floatcos(-Angle,degrees)),
                    ButtonInfo[buttonid][Pos][2] - 0.63
                );

                ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
                SetTimerEx("OnPlayerPressButton_Delay", 500, false, "ii", playerid, buttonid);
            }
        }


        #if defined DEBUG

        else if (newkeys & KEY_HANDBRAKE)
        {
            if (PlayerInfo[playerid][SelectedButton] != INVALID_BUTTON_ID)
            {
                switch (PlayerInfo[playerid][MSpeed])
                {
                    case 1.0 : { PlayerInfo[playerid][MSpeed] =  2.5; String = "Slow"; }
                    case 2.5 : { PlayerInfo[playerid][MSpeed] =  5.0; String = "Normal"; }
                    case 5.0 : { PlayerInfo[playerid][MSpeed] = 15.0; String = "Fast"; }
                    default  : { PlayerInfo[playerid][MSpeed] =  1.0; String = "Very Slow"; }
                }
           
                format(String, sizeof(String), "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Movement speed~n~~r~%s~w~!", String);
                GameTextForPlayer(playerid, String, 1500, 3);
            }
        }
       
        else if (newkeys & KEY_WALK)
        {
            if (PlayerInfo[playerid][SelectedButton] != INVALID_BUTTON_ID)
                OnPlayerCommandText(playerid, "/button deselect");
            else
                OnPlayerCommandText(playerid, "/button select");
        }
       
        #endif

    }
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
public OnObjectMoved(objectid)
{
    new buttonid = FS_GetObjectButtonID(objectid);
   
    if (buttonid != INVALID_BUTTON_ID)
    {
        new Float:ObjectPos[3];
        GetObjectPos(objectid, ObjectPos[0], ObjectPos[1], ObjectPos[2]);
        ButtonInfo[buttonid][Pos][0] = ObjectPos[0];
        ButtonInfo[buttonid][Pos][1] = ObjectPos[1];
        ButtonInfo[buttonid][Pos][2] = ObjectPos[2];
        ButtonInfo[buttonid][Moving] = false;
        CallRemoteFunction("OnButtonMoved", "i", buttonid);
    }
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
public OnPlayerConnect(playerid)
{
    #if defined DEBUG
        if (PlayerInfo[playerid][SelectedButton] != INVALID_BUTTON_ID)
        {
            PlayerInfo[playerid][SelectedButton] = INVALID_BUTTON_ID;
            PlayerInfo[playerid][MSpeed] = 5.0;
            KillTimer(PlayerInfo[playerid][TimerID]);
        }
    #endif
   
    ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 10.0, 0, 0, 0, 0, 0);
    return 1;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
public OnGameModeInit()
{
    #if defined DEBUG
        FS_PrintButtonsInfos();
    #endif

    return true;
}
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
public OnGameModeExit()
{
    #if defined DEBUG
        FS_PrintButtonsInfos();
    #endif
   
    for (new buttonid = 1; buttonid <= MAX_BUTTONS; buttonid ++)
        if (ButtonInfo[buttonid][Created])
            FS_DestroyButton(buttonid);

    return true;
}
/*----------------------------------------------------------------------------*/










/*----------------------------------------------------------------------------*/
#if defined DEBUG



    argpos(const string[], idx = 0, sep = ' ')
    {
        for(new i = idx, j = strlen(string); i < j; i++)
            if (string[i] == sep && string[i+1] != sep)
                return i+1;

        return -1;
    }



    public OnPlayerCommandText(playerid, cmdtext[])
    {
        if (strlen(cmdtext) > 50)
        {
            SendClientMessage(playerid, 0xFF0000FF, "Invalid command length (exceeding 50 characters)");
            return true;
        }
       
       
        if(!strcmp(cmdtext, "/button", .length = 7))
        {
       
            if (!IsPlayerAdmin(playerid))
                return true;
           
           
           
            new arg1 = argpos(cmdtext);



            if (!cmdtext[arg1])
            {
                SendClientMessage(playerid, 0xFF0000FF, "Button Editor's commands:");
                SendClientMessage(playerid, 0xFFFFFFFF, "\"/button create\" - Create a button at your position, then type \"/button select\" to move this button.");
                SendClientMessage(playerid, 0xFFFFFFFF, "\"/button select <opt:buttonid>\" - If you don't use the optional parameter, it will select the closest button.");
                SendClientMessage(playerid, 0xFFFFFFFF, "\"/button save <opt:comment>\" - Save the positions of the selected button, optionally with a short comment.");
                SendClientMessage(playerid, 0xFFFFFFFF, "\"/button deselect\" - Deselect the selected button, this stops the editing mode.");
                SendClientMessage(playerid, 0xFF0000FF, "Button Editor's keys:");
                SendClientMessage(playerid, 0xFFFFFFFF, "Use Directional key to move the selected button forward, backward, to the left and to the right.");
                SendClientMessage(playerid, 0xFFFFFFFF, "Use Look Behind + Left or Right to rotate the selected button.");
                SendClientMessage(playerid, 0xFFFFFFFF, "Use Secondary Fire to change the movement speed.");
                SendClientMessage(playerid, 0xFFFFFFFF, "Use Walk to toggle Deselect/Select closest button.");
                return true;
            }



            else if (!strcmp(cmdtext[arg1], "create", .length = 6))
            {
                new Float:PlayerPos[4], buttonid;
                GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
                GetPlayerFacingAngle(playerid, PlayerPos[3]);

                buttonid = FS_CreateButton(PlayerPos[0],PlayerPos[1],PlayerPos[2] + 0.63,PlayerPos[3]);
                format(String, sizeof(String), "Buttonid %d created! Select it with \"/button select\"", buttonid);
                SendClientMessage(playerid, 0x00FF00FF, String);
                return true;
            }



            else if (!strcmp(cmdtext[arg1], "select", .length = 6))
            {
                new arg2 = argpos(cmdtext, arg1),
                    buttonid;
               
                if (PlayerInfo[playerid][SelectedButton] != INVALID_BUTTON_ID)
                    KillTimer(PlayerInfo[playerid][TimerID]);
                   
                if (!cmdtext[arg2])
                {
                    new Float:PlayerPos[3];
                    GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
                    buttonid = GetClosestButton(PlayerPos);

                    if (buttonid == INVALID_BUTTON_ID)
                        SendClientMessage(playerid, 0xFF0000FF, "Can't find a button! You may need to create one!");
                   
                    else
                    {
                        PlayerInfo[playerid][SelectedButton] = buttonid;
                        PlayerInfo[playerid][TimerID] = SetTimerEx("ButtonEditor_Timer", 50, true, "ii", playerid, PlayerInfo[playerid][SelectedButton]);
                        TogglePlayerControllable(playerid, false);
                        format(String, sizeof(String), "Buttonid %d selected! Once you placed it where you want, save it with \"/button save <comment>\"", buttonid);
                        SendClientMessage(playerid, 0x00FF00FF, String);
                    }
                }
                else
                {
                    buttonid = strval(cmdtext[arg2]);
                   
                    if (FS_IsValidButton(buttonid))
                    {
                        PlayerInfo[playerid][SelectedButton] = buttonid;
                        PlayerInfo[playerid][TimerID] = SetTimerEx("ButtonEditor_Timer", 50, true, "ii", playerid, PlayerInfo[playerid][SelectedButton]);
                        TogglePlayerControllable(playerid, false);
                        format(String, sizeof(String), "Buttonid %d selected! Once you placed it where you want, save it with \"/button save\"", buttonid);
                        SendClientMessage(playerid, 0x00FF00FF, String);
                    }
                   
                    else
                        SendClientMessage(playerid, 0xFF0000FF, "This buttonid is invalid!");

                }
                return true;
            }



            else if (!strcmp(cmdtext[arg1], "save", .length = 4))
            {
                new arg2 = argpos(cmdtext, arg1),
                    buttonid = PlayerInfo[playerid][SelectedButton];
               
                if (buttonid != INVALID_BUTTON_ID)
                {
                    new File:savedbuttons_file = fopen("savedbuttons.txt", io_append);

                    if (!cmdtext[arg2])
                    {
                        format
                        (
                            String,
                            sizeof(String),
                            "CreateButton(%.2f, %.2f, %.2f, %.1f);\r\n",
                            ButtonInfo[buttonid][Pos][0],
                            ButtonInfo[buttonid][Pos][1],
                            ButtonInfo[buttonid][Pos][2],
                            float(floatround(ButtonInfo[buttonid][Pos][3])%360)
                        );
                    }
                    else
                    {
                        format
                        (
                            String,
                            sizeof(String),
                            "CreateButton(%.2f, %.2f, %.2f, %.1f); // %s\r\n",
                            ButtonInfo[buttonid][Pos][0],
                            ButtonInfo[buttonid][Pos][1],
                            ButtonInfo[buttonid][Pos][2],
                            float(floatround(ButtonInfo[buttonid][Pos][3])%360),
                            cmdtext[arg2]
                        );
                    }
                   
                    fwrite(savedbuttons_file,String);
                    fclose(savedbuttons_file);
                   
                    SendClientMessage(playerid, 0x00FF00FF, "Button's informations saved in \"/scriptfiles/savedbuttons.txt\"!");
                }
                else
                    SendClientMessage(playerid, 0xFF0000FF, "Umm..Select a button first?");

                return true;
            }



            else if (!strcmp(cmdtext[arg1], "deselect", .length = 6))
            {
                if (PlayerInfo[playerid][SelectedButton] != INVALID_BUTTON_ID)
                {
                    format(String, sizeof(String), "Buttonid %d deselected!", PlayerInfo[playerid][SelectedButton]);
                    SendClientMessage(playerid, 0x00FF00FF, String);
                    PlayerInfo[playerid][SelectedButton] = INVALID_BUTTON_ID;
                    TogglePlayerControllable(playerid, true);
                    KillTimer(PlayerInfo[playerid][TimerID]);
                }
                else
                    SendClientMessage(playerid, 0xFF0000FF, "Umm..Select a button first?");

                return true;
            }


           
            return false;
        }
       
        return false;
    }




    forward ButtonEditor_Timer(playerid, buttonid);
    public ButtonEditor_Timer(playerid, buttonid)
    {
        new PlayerKeys[3],
            Float:Move_Sin = PlayerInfo[playerid][MSpeed]/100.0 * floatsin(-ButtonInfo[buttonid][Pos][3], degrees),
            Float:Move_Cos = PlayerInfo[playerid][MSpeed]/100.0 * floatcos(-ButtonInfo[buttonid][Pos][3], degrees);
           
        GetPlayerKeys(playerid,PlayerKeys[0],PlayerKeys[1],PlayerKeys[2]);
       
        if (PlayerKeys[0] + PlayerKeys[1] + PlayerKeys[2] != 0 && PlayerKeys[0] != KEY_HANDBRAKE)
        {
            if (PlayerKeys[0] & 512)
            {
                if (PlayerKeys[2] == KEY_LEFT)
                    ButtonInfo[buttonid][Pos][3] += PlayerInfo[playerid][MSpeed]/5.0;

                else if (PlayerKeys[2] == KEY_RIGHT)
                    ButtonInfo[buttonid][Pos][3] -= PlayerInfo[playerid][MSpeed]/5.0;
               
                format
                (
                    String,
                    sizeof(String),
                    "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Rotating buttonid ~r~%d ~n~~w~Angle=~r~%d",
                    buttonid,
                    floatround(ButtonInfo[buttonid][Pos][3]) % 360
                );
               
                GameTextForPlayer(playerid, String, 1500, 3);
            }
           
            else
            {
                if (PlayerKeys[1] == KEY_UP)
                {
                    ButtonInfo[buttonid][Pos][0] += Move_Sin;
                    ButtonInfo[buttonid][Pos][1] += Move_Cos;
                }
                else if (PlayerKeys[1] == KEY_DOWN)
                {
                    ButtonInfo[buttonid][Pos][0] -= Move_Sin;
                    ButtonInfo[buttonid][Pos][1] -= Move_Cos;
                }
       
                if (PlayerKeys[2] == KEY_LEFT)
                {
                    ButtonInfo[buttonid][Pos][0] -= Move_Cos;
                    ButtonInfo[buttonid][Pos][1] += Move_Sin;
                }
                else if (PlayerKeys[2] == KEY_RIGHT)
                {
                    ButtonInfo[buttonid][Pos][0] += Move_Cos;
                    ButtonInfo[buttonid][Pos][1] -= Move_Sin;
                }
       
                format
                (
                    String,
                    sizeof(String),
                    "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~Moving buttonid ~r~%d ~n~~w~X=~r~%.2f ~w~Y=~r~%.2f",
                    buttonid,
                    ButtonInfo[buttonid][Pos][0],
                    ButtonInfo[buttonid][Pos][1]
                );
               
                GameTextForPlayer(playerid, String, 1500, 3);
            }
           
            FS_SetButtonPos
            (
                buttonid,
                ButtonInfo[buttonid][Pos][0],
                ButtonInfo[buttonid][Pos][1],
                ButtonInfo[buttonid][Pos][2],
                ButtonInfo[buttonid][Pos][3]
            );
        }
    }




#endif
/*----------------------------------------------------------------------------*/
Seems to be compiling fine.
Reply
#3

Oh.. I was using the old version.. thanks very much for helping me dude!! Rep +1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)