My object problem
#1

I'm making a stretcher command which will attach a created object to the player

here's my /getstretcher cmd:

pawn Код:
PlayerStat[playerid][StretcherObject] = CreateObject(2146, X, Y, Z, 0, 0, 0, 75.0);
            AttachObjectToPlayer(PlayerStat[playerid][StretcherObject], playerid,  -0.506504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000);
and this is my /removestretcher cmd:

pawn Код:
DestroyObject(PlayerStat[playerid][StretcherObject]);
when i use /removestretcher then try to get another stretcher using /getstretcher it doesn't work
Reply
#2

Quote:
Originally Posted by Soumi
Посмотреть сообщение
it doesn't work
Explain please.
Reply
#3

Ok, i used /getstretcher which creates an Stretcher object then attach this object to the player.

pawn Код:
PlayerStat[playerid][StretcherObject] = CreateObject(2146, X, Y, Z, 0, 0, 0, 75.0);
            AttachObjectToPlayer(PlayerStat[playerid][StretcherObject], playerid,  -0.506504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000);
this works, so i tested the /removestretcher command.

pawn Код:
DestroyObject(PlayerStat[playerid][StretcherObject]);
and it destroyed the stretcher object (Works)

But when i wanted to use /getstretcher again after destroying that object, its not working nothing happens
Reply
#4

You're using the DestroyObject wrong.

https://sampwiki.blast.hk/wiki/DestroyObject
Reply
#5

Quote:
Originally Posted by ElieJabbour
Посмотреть сообщение
You're using the DestroyObject wrong.

https://sampwiki.blast.hk/wiki/DestroyObject
He is using it correctly. Instead of making accusations, why not tell him how to solve the problem?

Quote:
Originally Posted by Soumi
Посмотреть сообщение
But when i wanted to use /getstretcher again after destroying that object, its not working
nothing happens
Try mine:

PHP код:
new Object[MAX_PLAYERS];
YCMD:getstretcher(playeridparams[], help)
{
    new 
Float:XFloat:YFloat:Z;
    
#pragma unused help
    #pragma unused params
    
Object[playerid] = CreateObject(2146XYZ00075.0);
     
AttachObjectToPlayer(Object[playerid], playerid,  -0.5065041.5049880.0315840.00000089.5666350.000000);
    return 
1;
}
YCMD:removestretcher(playeridparams[], help)
{
    
#pragma unused help
    #pragma unused params
    
DestroyObject(Object[playerid]);
    return 
1;

Reply
#6

Quote:
Originally Posted by ElieJabbour
Посмотреть сообщение
You're using the DestroyObject wrong.

https://sampwiki.blast.hk/wiki/DestroyObject
Why you said so?

I don't see any problem with your little code. Perhaps there's something to do with your command in another line.
Is the object created or not?
Reply
#7

Quote:
Originally Posted by Kush
Посмотреть сообщение
He is using it correctly. Instead of making accusations, why not tell him how to solve the problem?



Try mine:

PHP код:
new Object[MAX_PLAYERS];
YCMD:getstretcher(playeridparams[], help)
{
    new 
Float:XFloat:YFloat:Z;
    
#pragma unused help
    #pragma unused params
    
Object[playerid] = CreateObject(2146XYZ00075.0);
     
AttachObjectToPlayer(Object[playerid], playerid,  -0.5065041.5049880.0315840.00000089.5666350.000000);
    return 
1;
}
YCMD:removestretcher(playeridparams[], help)
{
    
#pragma unused help
    #pragma unused params
    
DestroyObject(Object[playerid]);
    return 
1;

it's looks just like my command

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
Why you said so?

I don't see any problem with your little code. Perhaps there's something to do with your command in another line.
Is the object created or not?
Yes the object is created and it's attached to the player but after using Destroying the object (which works also)
i can't use the /getstretcher command anymore.
Reply
#8

I mean is the object created again (When you do /getstretcher) after it destroyed?
Reply
#9

Quote:
Originally Posted by varthshenon
Посмотреть сообщение
I mean is the object created again (When you do /getstretcher) after it destroyed?
No, that's the problem
Reply
#10

Quote:
Originally Posted by Soumi
Посмотреть сообщение
it's looks just like my command



Yes the object is created and it's attached to the player but after using Destroying the object (which works also)
i can't use the /getstretcher command anymore.
It's your command except Object is defined as a global var.

I've tested it out and you can remove and get the stretcher how many times you would like.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)