shouldnt this work? (i seriously have been trying to fix)
#1

PROBLEM
Код:
CMD:laser_red(playerid, params[])
    {
		CreateObject(18643,0.0,0.0,0.0);
        SetPlayerAttachedObject( playerid, 0, 18643, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
        return 1;
    }
    CMD:laser_blue(playerid, params[])
    {
        CreateObject(19080,0.0,0.0,0.0);
        SetPlayerAttachedObject(playerid, 1, 19080, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
        return 1;
    }
    CMD:laser_pink(playerid, params[])
    {
        CreateObject(19081,0.0,0.0,0.0);
        SetPlayerAttachedObject( playerid, 2, 19081, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
        return 1;
    }
SOLUTION

Код:
CMD:lazer(playerid, params[])
{
    new option[64];
    if(!sscanf(params, "s", option))
    {
        if(strcmp(option,"red",true) == 0)
        {
            SetPlayerAttachedObject( playerid, 0, 18643, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        if(strcmp(option,"blue",true) == 0)
        {
            SetPlayerAttachedObject(playerid, 1, 19080, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        if(strcmp(option,"pink",true) == 0)
        {
            SetPlayerAttachedObject( playerid, 2, 19081, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        if(strcmp(option,"orange",true) == 0)
        {
            SetPlayerAttachedObject( playerid, 3, 19082, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        if(strcmp(option,"green",true) == 0)
        {
            SetPlayerAttachedObject( playerid, 4, 19083, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        if(strcmp(option,"yellow",true) == 0)
        {
            SetPlayerAttachedObject( playerid, 5, 19084, 5, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
            return 1;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Invalid Colour!");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /lazer [Red/Blue/Pink/Orange/Green/Yellow]");
}
Reply
#2

No. You have all the "CreateObject" Ids = 0,0,0,

'You should change it to, AttachObjectToPlayer or AttachObjectToVehicle
Reply
#3

You shouldn't first create the object when using SetPlayerAttachedObject. https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject
About the unknown command, try not using an underscore...
Reply
#4

If you are using ZCMD, make sure you have there callbacks in your script.
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	return 1;
}
And make sure to remove the OnPlayerCommandText callback from your script.

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
You shouldn't first create the object when using SetPlayerAttachedObject. https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject
About the unknown command, try not using an underscore...
Exactly!
SetPlayerAttachedObject is like CreateObject and AttachObjectToPlayer combined.
Reply
#5

Quote:
Originally Posted by Shetch
Посмотреть сообщение
If you are using ZCMD, make sure you have there callbacks in your script.
Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	return 1;
}
Actually, it makes no difference.
What's the point of adding empty callbacks - he will add them if he's gonna use them for something, lol.
Reply
#6

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
Actually, it doesn't make any difference.
What's the point of adding empty callbacks - he will add them if he's gonna use them for something, lol.
When those are not added, the server returns "SERVER: Unknown command!", doesn't it? O_O

EDIT:
Ignore my post, I tested it out myself, everything should work even without those two callbacks.
Reply
#7

If i do it without createobject i dont get unknown command but the object never spawns,thats why i added the createobject
Reply
#8

Dude, you don't even need to create the object before, but if you do, define a variable for Lazer[MAX_PLAYERS] in top of script, than Lazer[playerid] = CreateObject(bla bla bla); and than the attachment, and in object place in attachment, use Lazer[playerid].

But, i don't think that command format would work... :/
Something like this should do it:

pawn Код:
CMD:lazer(playerid, params[])
{
    new option[64];
    if(!sscanf(params, "s", option))
    {
        if(strcmp(option,"red",true) == 0)
        {
            //Red Lazer Attaching Code
        }
        if(strcmp(option,"blue",true) == 0)
        {
            //Blue Lazer Attaching Code
        }
        if(strcmp(option,"pink",true) == 0)
        {
            //Pink Lazer Attaching Code
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "Invalid Option.");
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /lazer [Red/Blue/Pink]");
}
Reply
#9

Try this.
Код:
CMD:laser_red(playerid, params[])
{
	new obj;
	obj = CreateObject(18643,0.0,0.0,0.0);
	AttachObjectToPlayer(obj, playerid, 1.5, 0.5, 0.0, 0.0, 1.5, 2);
	return 1;
}
Reply
#10

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Try this.
Код:
CMD:laser_red(playerid, params[])
{
	new obj;
	obj = CreateObject(18643,0.0,0.0,0.0);
	AttachObjectToPlayer(obj, playerid, 1.5, 0.5, 0.0, 0.0, 1.5, 2);
	return 1;
}
Read the damn function before bugging him.

https://sampwiki.blast.hk/wiki/SetPlayerAttachedObject
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)