SA-MP Forums Archive
Object Not Attaching plz Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Object Not Attaching plz Help (/showthread.php?tid=332185)



Object Not Attaching plz Help - Elias_Haddad - 07.04.2012

Hey Guys Today i was making a vip cmd to attach object i done it without errors but when i use the cmd the object dont attach , here is the code :
pawn Код:
if(strcmp(cmd, "/vobj", true) == 0)
       {
        new Float:x, Float:y, Float:z, Float:ang;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,ang);
        if(IsPlayerVipMember(playerid))
        {
        AttachObjectToPlayer(18856,playerid,x, y, z, x, y, z);
        }
        else SendClientMessage(playerid, LIGHTBLUE,"StuntProz Bot: You Arent A Vip To Use This Cmd");
        return 1;
        }
Plz I Need Help . Thx In Advance


Re: Object Not Attaching plz Help - Shabi RoxX - 07.04.2012

pawn Код:
AttachObjectToPlayer(18856,playerid,x, y, z, x, y, z);
These pos are relative to PlayerPos it means x+x > players pos X's X . Use 0,0,0,0,0,0 Like:

pawn Код:
AttachObjectToPlayer(18856,playerid,0, 0, 0, 0, 0, 0);//pos relative to player pos :)



Re: Object Not Attaching plz Help - Manuel_P - 07.04.2012

You need to Create the object first (I think, it's like that for when you attach objects to vehicles, not sure if that's for players as well)

Код:
new pObject;
pObject = CreateObject(18856, x, y, z, etc)
AttachObjectToPlayer(pObject,playerid,x, y, z, x, y, z);
I noticed you use the floats for the object position also for the object rotation, you can't do that, name them rotX, rotY, and rotZ, for example


Re: Object Not Attaching plz Help - Shabi RoxX - 07.04.2012

This too ^^


Re: Object Not Attaching plz Help - Elias_Haddad - 07.04.2012

Thx For Fast Reply Gonna Try It Now


Re: Object Not Attaching plz Help - Elias_Haddad - 07.04.2012

pawn Код:
if(strcmp(cmd, "/vobj", true) == 0)
       {
        new Float:x, Float:y, Float:z, Float:ang;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,ang);
        if(IsPlayerVipMember(playerid))
        {
        AttachObjectToPlayer(18856,playerid,0, 0, 0, 0, 0, 0);
        }
        else SendClientMessage(playerid, LIGHTBLUE,"StuntProz Bot: You Arent A Vip To Use This Cmd");
        return 1;
        }
This is the code now but im still not getting object attached


Re: Object Not Attaching plz Help - Shabi RoxX - 07.04.2012

Where You create the object ?

pawn Код:
Object = CreateObject(18856, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);
Try this:
pawn Код:
if(strcmp(cmd, "/vobj", true) == 0)
       {
        new Float:x, Float:y, Float:z, Float:ang,Object;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,ang);
        if(IsPlayerVipMember(playerid))
        {
 Object = CreateObject(18856, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);//so first create object and then attach by object id that we store in object variable
        AttachObjectToPlayer(Object,playerid,0, 0, 0, 0, 0, 0);//attach Object to player
        }
        else SendClientMessage(playerid, LIGHTBLUE,"StuntProz Bot: You Arent A Vip To Use This Cmd");
        return 1;
        }



Re: Object Not Attaching plz Help - Elias_Haddad - 07.04.2012

THX!!! it worked


Re: Object Not Attaching plz Help - Elias_Haddad - 07.04.2012

Plz Any Idea How to Make Cmd To Remove That Object? I Made one with DestroyObject(Object);
But i Get error 017 : Undefined symbol "Object"
Код:
C:\Users\User\Desktop\games\gamemode\StuntProz\filterscripts\LuxAdmin.pwn(7253) : error 017: undefined symbol "Object"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
and this is the cmd that i made
pawn Код:
if(strcmp(cmd, "/vcage", true) == 0)
               {
                new Float:x, Float:y, Float:z, Float:ang,Object;
                GetPlayerPos(playerid,x,y,z);
                GetPlayerFacingAngle(playerid,ang);
                if(IsPlayerVipMember(playerid))
                {
                new vehicleid = GetPlayerVehicleID(playerid);
                Object = CreateObject(18856, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);//so first create object and then attach by object id that we store in object variable
                AttachObjectToVehicle(Object,vehicleid,0, 0, 0, 0, 0, 0);//attach Object to player
                }
                else SendClientMessage(playerid, LIGHTBLUE,"StuntProz Bot: You Arent A Vip To Use This Cmd");
                return 1;
                }
                if(strcmp(cmd, "/vcageoff", true) == 0)
                {
                if(IsPlayerVipMember(playerid))
                {
                DestroyObject(Object);
                }
                return 1;
                }



Re: Object Not Attaching plz Help - Shabi RoxX - 07.04.2012

The variable "Object" is not Global variable you must make it global variable to use in other thing (cmd, functions):

Add this on TOP of your script
pawn Код:
new Object;//now this is global variable
Note: Delete Object var from your cmd : hERE
pawn Код:
new Float:x, Float:y, Float:z, Float:ang;//remove object var from here , no need for this we define it on top of our script