SA-MP Forums Archive
i've made a script, no error but doesn't work - 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: i've made a script, no error but doesn't work (/showthread.php?tid=659022)



i've made a script, no error but doesn't work - DarknesS1988 - 20.09.2018

I've made a script, no error but script doesn't work..
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define culoare 0xFFFFFFAA
new objectmodel[500];
forward WriteLog(string[]);
new 
Object;
COMMAND:createobject(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
Model;
        if(
sscanf(params,"i"Model)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/CreateObject [ObjectID]");
        new 
Float:X;
        new 
Float:Y;
        new 
Float:Z;
        
GetPlayerPos(playeridXYZ);
        
Object CreateObject(ModelXYZ000100.0);
        
EditObject(playerid,Object);
    }
    else
    {
        
SendClientMessage(playerid, -1"{FF0000}* {FF0000}ERROR: {FF0000}Only RCON can use this command !");
    }
    return 
1;
}
COMMAND:editobject(playeridparams[])
{
    new 
oid;
    if (!
sscanf(params"i",oid ))
    {
        
EditObject(playeridoid);
        return 
1;
    }else{
SendClientMessage(playerid,culoare,"USE : /editobject [objectid]");SendClientMessage(playerid,culoare,"INFO :Type /objects for a list of created objects"); return 1;}
    
}
COMMAND:gotoobject(playeridparams[])
{
    new 
oid;
    if (!
sscanf(params"i",oid ))
    {
        new 
Float:xoFloat:yoFloat:zo;
        
GetObjectPos(oidxoyozo);
        
SetPlayerPos(playerid,xo+1,yo+1,zo+1);
        return 
1;
    }else{
SendClientMessage(playerid,culoare,"Use :/gotoobject[objectid]"); return 1;}
}
COMMAND:ohelp(playerid,params[])
{
    
SendClientMessage(playerid,culoare,"/addobject || /editobject ||/gotoobject || /objects || /savemap");
    
SendClientMessage(playerid,culoare,"/oprew");
    return 
1;
}
COMMAND:savemap(playeridparams[])
{
    for(new 
0<=500i++)
    {
        new 
stringg[128];
        new 
Float:RotX,Float:RotY,Float:RotZ;
        
GetObjectRot(iRotXRotYRotZ);
        new 
Float:xoFloat:yoFloat:zo;
        
GetObjectPos(ixoyozo);
        if(
xo!=&& yo!=&& zo!=0)
        {
            
format(stringgsizeof(stringg), "CreateObject(%d,%f,%f,%f,%f,%f,%f);",objectmodel[i],xo,yo,zo,RotX,RotY,RotZ,90);
            
WriteLog(stringg);
        }
        
    }
    new 
stringg[128];
    
format(stringgsizeof(stringg), "________________//\\_______________");
    
WriteLog(stringg);
    
SendClientMessage(playerid,culoare,"All Objects have been saved to mapa.txt");
    return 
1;
}
COMMAND:objects(playeridparams[])
{
    
SendClientMessage(playerid,culoare,"___________L I S T______________");
    for(new 
1<=500i++)
    {
        new 
stringg[128];
        new 
Float:RotX,Float:RotY,Float:RotZ;
        
GetObjectRot(iRotXRotYRotZ);
        new 
Float:xoFloat:yoFloat:zo;
        
GetObjectPos(ixoyozo);
        if(
xo!=&& yo!=&& zo!=0)
        {
            
format(stringgsizeof(stringg), "ID:%dCreateObject(%d,%f,%f,%f,%f,%f,%f);",i,objectmodel[i],xo,yo,zo,RotX,RotY,RotZ);
            
SendClientMessage(playerid,culoare,stringg);
        }
    }
    
SendClientMessage(playerid,culoare,"________________________________");
    return 
1;
}
public 
WriteLog(string[])
{
    new 
entry[192];
    
format(entrysizeof(entry), "%s\n",string);
    new 
File:hFile;
    
hFile fopen("mapa.txt"io_append);
    
fwrite(hFileentry);
    
fclose(hFile);
    return 
1;
}
public 
OnPlayerEditObject(playeridplayerobjectobjectidresponseFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ)
{
    new 
Float:oldXFloat:oldYFloat:oldZ,
    
Float:oldRotXFloat:oldRotYFloat:oldRotZ;
    
GetObjectPos(ObjectoldXoldYoldZ);
    
GetObjectRot(ObjectoldRotXoldRotYoldRotZ);
    if(!
playerobject)
    {
        if(!
IsValidObject(Object)) return;
        
MoveObject(ObjectfXfYfZ10.0fRotXfRotYfRotZ);
    }

And i've made another one but it works and it's without save, edit object How do i add to it but it must work

here's working script:

PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
new Object;
CMD:createobject(playeridparams[])
{
    if(
IsPlayerAdmin(playerid))
    {
        new 
Model;
        if(
sscanf(params,"i"Model)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/CreateObject [ObjectID]");
        new 
Float:X;
        new 
Float:Y;
        new 
Float:Z;
        
GetPlayerPos(playeridXYZ);
        
Object CreateObject(ModelXYZ000100.0);
        
EditObject(playerid,Object);
    }
    else
    {
        
SendClientMessage(playerid, -1"{FF0000}* {FF0000}ERROR: {FF0000}Only RCON can use this command !");
    }
    return 
1;
}
public 
OnPlayerEditObject(playeridplayerobjectobjectidresponseFloat:fXFloat:fYFloat:fZFloat:fRotXFloat:fRotYFloat:fRotZ)
{
    new 
Float:oldXFloat:oldYFloat:oldZ,
    
Float:oldRotXFloat:oldRotYFloat:oldRotZ;
    
GetObjectPos(ObjectoldXoldYoldZ);
    
GetObjectRot(ObjectoldRotXoldRotYoldRotZ);
    if(!
playerobject)
    {
        if(!
IsValidObject(Object)) return;
        
MoveObject(ObjectfXfYfZ10.0fRotXfRotYfRotZ);
    }




Re: i've made a script, no error but doesn't work - coool - 21.09.2018

Do you get anything in Server_Logs.txt?


Re: i've made a script, no error but doesn't work - UFF - 21.09.2018

Quote:
Originally Posted by coool
Посмотреть сообщение
Do you get anything in Server_Logs.txt?
He means , he need to add save, edit object options in that command.


Re: i've made a script, no error but doesn't work - DarknesS1988 - 21.09.2018

Quote:
Originally Posted by UFF
Посмотреть сообщение
He means , he need to add save, edit object options in that command.
Exactly! Nothing found in server log.


Re: i've made a script, no error but doesn't work - DarknesS1988 - 23.09.2018

Anyone please help. Iam giving reputation for help


Re: i've made a script, no error but doesn't work - Florin48 - 23.09.2018

why you dont use map editor for creating a good map?


Re: i've made a script, no error but doesn't work - DarknesS1988 - 23.09.2018

Quote:
Originally Posted by Florin48
Посмотреть сообщение
why you dont use map editor for creating a good map?
That's the point. I don't want to use map editor. I just want my command to be able to edit created objects in game. I don't want to save those objects in server. I just want to create them for fun, for some events.
I've made a command to create object, yes it works but i want to also be able to edit it in game.


Re: i've made a script, no error but doesn't work - AdamCooper - 24.09.2018

u use mysql?

and do u want the object to save or no i didnt understand.

the edit object not working to?


Re: i've made a script, no error but doesn't work - DarknesS1988 - 28.09.2018

Quote:
Originally Posted by AdamCooper
Посмотреть сообщение
u use mysql?

and do u want the object to save or no i didnt understand.

the edit object not working to?
I don't want to save object, thats useless.
Yep, editing is not working :/


Re: i've made a script, no error but doesn't work - Ferman - 28.09.2018

Maybe you can create first object and then make a command for editing or use timer?