SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/03/2020, 06:38 PM   #11
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

Quote:
Originally Posted by seventyone View Post
Thanks, but it doesn't work. In the game he says that they are not near objects
bump
seventyone is offline   Reply With Quote
Old 12/03/2020, 08:42 PM   #12
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 468
Reputation: 35
Default Re: Duplicate Object

Did you try fiddling with the range of the code SiaReyes gave you?
Adamoneoone is offline   Reply With Quote
Old 13/03/2020, 04:18 AM   #13
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 622
Reputation: 57
Default Re: Duplicate Object

Quote:
Originally Posted by seventyone View Post
bump
that code is only to duplicate CopObjectData not for roadblock.

Debug to find what's the problem
Code:
CMD:duplicate(playerid, params[])
{
    
     new cloneid, bool:found=false;
     print("Executed Duplicate Command");
     for(new i; i < MAX_COP_OBJECTS; i++) if(IsPlayerInRangeOfPoint(playerid, 5.0, CopObjectData[i][ObjX], CopObjectData[i][ObjX], CopObjectData[i][ObjX]))
     {
         found = true;
         cloneid = i;
         break;
     }
     
     printf("Found: %s, cloneid %i", found == True ? "True" : "False", cloneid);

     if(!found) return  SendClientMessage(playerid, -1, "You are not near any cop object");
     if(CopObjectData[cloneid][ObjCreated]) return  SendClientMessage(playerid, -1, "Object Doesn't not exists!");

     new id = GetFreeObjectID();
     if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
     printf("Slot ID Specified: %d", id);
     CopObjectData[id][ObjCreated] = true;

     GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);

     printf("OBject Owner: %s", CopObjectData[id][Owner]);

     CopObjectData[id][Type] = CopObjectData[cloneid][Type];
     CopObjectData[id][ObjModel] = CopObjectData[cloneid][ObjModel];
     CopObjectData[id][ObjInterior] =  CopObjectData[cloneid][ObjInterior];
     CopObjectData[id][ObjVirtualWorld] = CopObjectData[cloneid][ObjVirtualWorld];
     CopObjectData[id][ObjX] = CopObjectData[cloneid][ObjX];
     CopObjectData[id][ObjY] = CopObjectData[cloneid][ObjY];
     CopObjectData[id][ObjZ] = CopObjectData[cloneid][ObjZ];
     CopObjectData[id][ObjRX] = CopObjectData[cloneid][ObjRX];
     CopObjectData[id][ObjRY] = CopObjectData[cloneid][ObjRY];
     CopObjectData[id][ObjRZ] = CopObjectData[cloneid][ObjRZ];
     CopObjectData[id][ObjID] = CreateDynamicObject(CopObjectData[id][ObjModel], x, y, z+2, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
     CopObjectData[id][ObjArea] = -1;

     printf("OBject Model: %d", CopObjectData[id][ObjModel]);

     new string[96];
     format(string, sizeof(string), "Police Line (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
     CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 0.35, 5.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
     InsertObjectToDB(id);
     print("Execution of Duplicate Command Ended!");
     return 1;

}

Last edited by SiaReyes; 13/03/2020 at 01:19 PM.
SiaReyes is offline   Reply With Quote
Old 18/03/2020, 07:26 PM   #14
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

Quote:
Originally Posted by SiaReyes View Post
that code is only to duplicate CopObjectData not for roadblock.

Debug to find what's the problem
Code:
CMD:duplicate(playerid, params[])
{
    
     new cloneid, bool:found=false;
     print("Executed Duplicate Command");
     for(new i; i < MAX_COP_OBJECTS; i++) if(IsPlayerInRangeOfPoint(playerid, 5.0, CopObjectData[i][ObjX], CopObjectData[i][ObjX], CopObjectData[i][ObjX]))
     {
         found = true;
         cloneid = i;
         break;
     }
     
     printf("Found: %s, cloneid %i", found == True ? "True" : "False", cloneid);

     if(!found) return  SendClientMessage(playerid, -1, "You are not near any cop object");
     if(CopObjectData[cloneid][ObjCreated]) return  SendClientMessage(playerid, -1, "Object Doesn't not exists!");

     new id = GetFreeObjectID();
     if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Limited.");
     printf("Slot ID Specified: %d", id);
     CopObjectData[id][ObjCreated] = true;

     GetPlayerName(playerid, CopObjectData[id][Owner], MAX_PLAYER_NAME);

     printf("OBject Owner: %s", CopObjectData[id][Owner]);

     CopObjectData[id][Type] = CopObjectData[cloneid][Type];
     CopObjectData[id][ObjModel] = CopObjectData[cloneid][ObjModel];
     CopObjectData[id][ObjInterior] =  CopObjectData[cloneid][ObjInterior];
     CopObjectData[id][ObjVirtualWorld] = CopObjectData[cloneid][ObjVirtualWorld];
     CopObjectData[id][ObjX] = CopObjectData[cloneid][ObjX];
     CopObjectData[id][ObjY] = CopObjectData[cloneid][ObjY];
     CopObjectData[id][ObjZ] = CopObjectData[cloneid][ObjZ];
     CopObjectData[id][ObjRX] = CopObjectData[cloneid][ObjRX];
     CopObjectData[id][ObjRY] = CopObjectData[cloneid][ObjRY];
     CopObjectData[id][ObjRZ] = CopObjectData[cloneid][ObjRZ];
     CopObjectData[id][ObjID] = CreateDynamicObject(CopObjectData[id][ObjModel], x, y, z+2, 0.0, 0.0, a, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
     CopObjectData[id][ObjArea] = -1;

     printf("OBject Model: %d", CopObjectData[id][ObjModel]);

     new string[96];
     format(string, sizeof(string), "Police Line (ID: %d)\n{FFFFFF}Placed by %s", id, CopObjectData[id][Owner]);
     CopObjectData[id][ObjLabel] = CreateDynamic3DTextLabel(string, 0x3498DBFF, x, y, z + 0.35, 5.0, _, _, _, CopObjectData[id][ObjVirtualWorld], CopObjectData[id][ObjInterior]);
     InsertObjectToDB(id);
     print("Execution of Duplicate Command Ended!");
     return 1;

}
Thanks, but I have an error and I have no idea how to solve it.
error 001: expected token: "-string end-", but found "-identifier-"
seventyone is offline   Reply With Quote
Old 18/03/2020, 10:26 PM   #15
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 622
Reputation: 57
Default Re: Duplicate Object

I think it's printf line.
Code:
     printf("Found: %s, cloneid %i", found ? ("True") : ("False"), cloneid);
If not fixed, post the error line.
SiaReyes is offline   Reply With Quote
Old 19/03/2020, 08:15 PM   #16
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

Quote:
Originally Posted by SiaReyes View Post
I think it's printf line.
Code:
     printf("Found: %s, cloneid %i", found ? ("True") : ("False"), cloneid);
If not fixed, post the error line.
Thanks, but in game said:
"You are not near any cop object"
You can tell me how I change for all objects not just for Cop Object
Number of vehicle models: 1
[connection] incoming connection: 127.0.0.1:61832 id: 0
[join] Player has joined the server (0:127.0.0.1)
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
Executed Duplicate Command
Found: False, cloneid 0
[part] Player has left the server (0:1)
seventyone is offline   Reply With Quote
Old 22/03/2020, 03:53 PM   #17
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

buuummp
seventyone is offline   Reply With Quote
Old 23/03/2020, 02:43 AM   #18
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 622
Reputation: 57
Default Re: Duplicate Object

Code:
if(IsPlayerInRangeOfPoint(playerid, 5.0, CopObjectData[i][ObjX], CopObjectData[i][ObjY], CopObjectData[i][ObjZ]))
try this and check
SiaReyes is offline   Reply With Quote
Old 23/03/2020, 12:01 PM   #19
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

Quote:
Originally Posted by SiaReyes View Post
Code:
if(IsPlayerInRangeOfPoint(playerid, 5.0, CopObjectData[i][ObjX], CopObjectData[i][ObjY], CopObjectData[i][ObjZ]))
try this and check
Executed Duplicate Command
Found: True, cloneid 0
Executed Duplicate Command
Found: True, cloneid 0
Executed Duplicate Command
Found: True, cloneid 0

in game said Object Doesn't not exists!
seventyone is offline   Reply With Quote
Old 23/03/2020, 12:07 PM   #20
seventyone
Little Clucker
 
Join Date: Feb 2020
Posts: 31
Reputation: 0
Default Re: Duplicate Object

Nevermind, resolved. Thanks @SiaReyes
seventyone is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate object Ananisiki Scripting Help 3 20/11/2015 10:42 PM
Duplicate Key! norton2 Scripting Help 13 25/09/2015 11:14 AM
[Reqeust]Command to duplicate an object. faff Scripting Help 10 15/02/2013 02:23 PM
Why there isn't rotation when I duplicate an Object from map? Soap_MacTavish Scripting Help 2 07/02/2013 10:56 AM
duplicate car leetboi Scripting Help 2 26/11/2012 07:04 PM


All times are GMT. The time now is 03:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.