Merging FS with GM
#1

Hello, again...

I tried to merge filterscript with gamemode, I pasted code from filterscript into gamemode:

Код:
{
	if (strcmp("/arm", cmdtext, true, 10) == 0)
	{
	    PutRiotShieldOnArm(playerid);
		return 1;
	}
	if (strcmp("/armoff", cmdtext, true, 10) == 0)
	{
	        if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
	        if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
	}
	return 0;
}


RemoveItems(playerid)
{
	        if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
	        if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
}


PutRiotShieldOnArm(playerid)
{
	    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
		SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
}
But, when I paste this code in my gamemode under OnPlayerCommandText, it gives following errors:

Quote:

error 017: undefined symbol "PutRiotShieldOnArm"
undefined symbol "RemoveItems"
undefined symbol "PutRiotShieldOnArm"
warning 225: unreachable code

But when this code was in FS all worked correctly, but inside GM it gives errors...
Reply
#2

Try this
OnPlayerCommandText:
pawn Код:
if (strcmp("/arm", cmdtext, true, 10) == 0)
{
    PutRiotShieldOnArm(playerid);
    return 1;
}
if (strcmp("/armoff", cmdtext, true, 10) == 0)
{
    RemoveItems(playerid);
    return 1;
}
Somewhere in ur script:
pawn Код:
RemoveItems(playerid)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
}


PutRiotShieldOnArm(playerid)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
}
Reply
#3

error 017: undefined symbol "PutRiotShieldOnArm"
error 017: undefined symbol "RemoveItems"
error 017: undefined symbol "RemoveItems"
error 017: undefined symbol "PutRiotShieldOnArm"

...

I tried this :

Код:
	// COP TOOLS START
	
	if (strcmp("/arm", cmdtext, true, 10) == 0)
	{
	PutRiotShieldOnArm(playerid)
	{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
	}
    return 1;
	}
	if (strcmp("/armoff", cmdtext, true, 10) == 0)
	{
	RemoveItems(playerid)
	{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
	}
    return 1;
	}

	// COP TOOLS END
And then it gives only 2 errors:

error 017: undefined symbol "PutRiotShieldOnArm"
error 017: undefined symbol "RemoveItems"

Also this doesn't help.

Код:
	// COP TOOLS START
	
	if (strcmp("/arm", cmdtext, true, 10) == 0)
	{
	if(PutRiotShieldOnArm(playerid))
	{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
	}
    return 1;
	}
	if (strcmp("/armoff", cmdtext, true, 10) == 0)
	{
	if(RemoveItems(playerid))
	{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
	}
    return 1;
	}

	// COP TOOLS END
Reply
#4

The functions PutRiotShieldOnArm(playerid) and RemoveItems(playerid) should be put outside the callbacks

Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/arm", cmdtext, true, 10) == 0)
    {
        if(PutRiotShieldOnArm(playerid))
        {
            if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
            SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
        }
            return 1;
    }
    if (strcmp("/armoff", cmdtext, true, 10) == 0)
    {
        if(RemoveItems(playerid))
        {
            if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
                if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
        }
        return 1;
    }
    return 0;
}

PutRiotShieldOnArm(playerid)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    SetPlayerAttachedObject(playerid, 1, 18637, 3, 0.3, -0.2, 0, 180, 170, 270, 1, 1, 1);
    return 1;
}

RemoveItems(playerid)
{
    if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
    if(IsPlayerAttachedObjectSlotUsed(playerid,2)) RemovePlayerAttachedObject(playerid,2);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)