Object Not Attaching plz Help
#1

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
Reply
#2

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 :)
Reply
#3

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
Reply
#4

This too ^^
Reply
#5

Thx For Fast Reply Gonna Try It Now
Reply
#6

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
Reply
#7

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;
        }
Reply
#8

THX!!! it worked
Reply
#9

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;
                }
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)