drag sys problem
#1

the problem is:
Код:
C:\Documents and Settings\вм дммй\щемзп дтбегд\Drag sys.pwn(146) : error 021: symbol already defined: "strtok"
C:\Documents and Settings\вм дммй\щемзп дтбегд\Drag sys.pwn(161) : error 047: array sizes do not match, or destination array is too small
this the code:
Код:
#include <a_samp>
#include <dutils>
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_RED 0xAA3333AA
#define COLOR_NICEBLUE 0x25affeAA
#pragma unused ret_memcpy
new DragTimer[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256];
	new tmp[256];
	new string[256];
	new giveplayerid, idx;
	new sendername[MAX_PLAYER_NAME];
	new playername[MAX_PLAYER_NAME];
	cmd = strtok(cmdtext, idx);
	if (strcmp(cmd, "/drag", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		giveplayerid = strval(tmp);
  		if(!strlen(tmp))
		{
			SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /drag [playerid]");
			return 1;
		}
		if(!IsPlayerConnected(giveplayerid))
		{
			format(string, sizeof(string), "%d is not an active player.", giveplayerid);
			SendClientMessage(playerid,COLOR_GREY, string);
			return 1;
		}
		if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3)
		{
			SendClientMessage(playerid, 0xFF0000AA, "You are too far away from that player.");
			return 1;
		}
		if(giveplayerid == playerid)
		{
			SendClientMessage(playerid, COLOR_RED, "You cannot drag yourself!");
			return 1;
		}
		if(DragTimer[playerid] <= 0)
		{
			if(IsPlayerConnected(giveplayerid) == 1)
			{
				GetPlayerName(giveplayerid, sendername, sizeof(sendername));
   				GetPlayerName(playerid, playername, sizeof(playername));
    			format(string, sizeof(string), "%s catches %s's shirt and drags him with him", playername, sendername);
				ProxDetector(30.0, playerid, string, COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE);
				DragTimer[playerid] = SetTimerEx("Drag", 1000, 1, "ii", giveplayerid, playerid);
				return 1;
			}
		}
		return 1;
 	}
 	if (strcmp(cmd, "/leave", true) == 0)
	{
		if(DragTimer[playerid] >= 0)
		{
			KillTimer(DragTimer[playerid]);
			DragTimer[playerid] = 0;
			GetPlayerName(giveplayerid, sendername, sizeof(sendername));
	 		GetPlayerName(playerid, playername, sizeof(playername));
			format(string, sizeof(string), "%s leaves %s shirt", playername, sendername);
			ProxDetector(30.0, playerid, string, COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE,COLOR_NICEBLUE);
			return 1;
		}
		return 1;
    }
    return 0;
}
	
forward Drag(giveplayerid, playerid);
public Drag(giveplayerid, playerid)
{
	new Float:x, Float:y, Float:z;
 	GetPlayerPos(playerid, x, y, z);
  	SetPlayerPos(giveplayerid, x, y - 1, z);
   	SetPlayerInterior(GetPlayerInterior(giveplayerid),playerid);
    if(IsPlayerInAnyVehicle(playerid))
	{
		new newcar = GetPlayerVehicleID(playerid);
 		PutPlayerInVehicle(giveplayerid, newcar, 1);
	}
}
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
	{
		return -1.00;
	}
	GetPlayerPos(p1,x1,y1,z1);
	GetPlayerPos(p2,x2,y2,z2);
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
forward ProxDetector(Float:radi, playerid, ms[],col1,col2,col3,col4,col5);
public ProxDetector(Float:radi, playerid, ms[],col1,col2,col3,col4,col5)
{
	if(IsPlayerConnected(playerid))
	{
		new Float:posx, Float:posy, Float:posz;
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
			{
				GetPlayerPos(i, posx, posy, posz);
				tempposx = (oldposx -posx);
				tempposy = (oldposy -posy);
				tempposz = (oldposz -posz);
				if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
				{
					SendClientMessage(i, col1, ms);
				}
				else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
				{
					SendClientMessage(i, col2, ms);
				}
				else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
				{
					SendClientMessage(i, col3, ms);
				}
				else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
				{
					SendClientMessage(i, col4, ms);
				}
				else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
				{
					SendClientMessage(i, col5, ms);
				}
			}
			else
			{
				SendClientMessage(i, col1, ms);
			}
		}
	}
	return 1;
}
strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
Reply
#2

Remove this:
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#3

You already got strtok in the dutils.inc, delete that strtok stock.
EDIT: Too late
Reply
#4

but if i delte this i can drag any player from any distance
Reply
#5

Delete the stock, YOU ALREADY HAVE IT. Meaning you will not delete it! You will just delete an extra unneeded one.
Reply
#6

i delete but now anyone can drag and from very far distance
Reply
#7

Then put it back and delete it from dutils.inc?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)