Convoy Trucking

Hyde Park => GTA & SA-MP => Topic started by: Doc. on February 12, 2017, 10:14

Title: Need scripting help
Post by: Doc. on February 12, 2017, 10:14
Hi i need a cmd /setnight to set darkness on my test sv because it doesnt have that day/night thing its always day.I have no idea how to script this so if u can help me please do it C:-)
Title: Re: Need scripting help
Post by: Dr_Alio on February 12, 2017, 10:41
Something like this

CMD:settime(playerid, params[])
{
    new time, string[128];
    if(sscanf(params, "i", time)) return SendClientMessage(playerid, -1, "Usage: /settime [time]");
    if(time > 24 || time < 0) return SendClientMessage(playerid, -1, "Error: Invalid time!");
    SetWorldTime(time);
    format(string, sizeof(string), "Time set to %d", time);
    SendClientMessage(playerid, 0x00FF00FF, string);
    return 1;
}

or

CMD:setnight(playerid, params[])
{
    SetWorldTime(0); //midnight
    SendClientMessage(playerid, 0x00FF00FF, "Time set to midnight.");
    return 1;
}

Title: Re: Need scripting help
Post by: Doc. on February 12, 2017, 11:13
The second one looks easier, where do i input that?i mean which part of gamemod?
Title: Re: Need scripting help
Post by: Dr_Alio on February 12, 2017, 11:36
Just put it somewhere. I always have all the commands at the end of the code.

....
....
....
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

CMD:setnight(playerid, params[])
{
    SetWorldTime(0); //midnight
    SendClientMessage(playerid, 0x00FF00FF, "Time set to midnight.");
    return 1;
}

And you need to include #include <zcmd>
Title: Re: Need scripting help
Post by: Doc. on February 12, 2017, 11:57
grandlarc.pwn(14) : fatal error 100: cannot read from file: "zcmd"
Title: Re: Need scripting help
Post by: Dr_Alio on February 12, 2017, 12:05
Well yea cuz you need to add http://forum.sa-mp.com/showthread.php?t=91354 zcmd in to include folder of pawn
Title: Re: Need scripting help
Post by: Doc. on February 12, 2017, 12:08
Quote from: Dr_Alio on February 12, 2017, 12:05
Well yea cuz you need to add http://forum.sa-mp.com/showthread.php?t=91354 zcmd in to include folder of pawn
U got team viewer? Dont want to fck everything up Carl worked a lot to fix my streamer
Title: Re: Need scripting help
Post by: CarlJohnson on February 12, 2017, 13:43
Just download zcmd from SAMP forums and put it into /includes folder then include it in gamemode using #include <zcmd>, also you need sccanf 2 plugin file for 1st commad.

Title: Re: Need scripting help
Post by: CarlJohnson on February 12, 2017, 16:25
Well to avoid using ZCMD, you can do this.

public OnPlayerCommandText(playerid, cmdtext[])
{
     if(strcmp(cmdtext, "/night") == 0)
     {
         SetWorldTime(0); // or 12 'o clock
         SendClientMessage(playerid, 0x00FF00FF, "Time set to midnight.");
         return 1;
     }
     return 0;
}
Title: Re: Need scripting help
Post by: Doc. on February 12, 2017, 17:07
Quote from: CarlJohnson on February 12, 2017, 16:25
Well to avoid using ZCMD, you can do this.

public OnPlayerCommandText(playerid, cmdtext[])
{
     if(strcmp(cmdtext, "/night") == 0)
     {
         SetWorldTime(0); // or 12 'o clock
         SendClientMessage(playerid, 0x00FF00FF, "Time set to midnight.");
         return 1;
     }
     return 0;
}

Alio is doing some things now to fix becuz he broke the server,stay in touch we'll need your help=)))
Title: Re: Need scripting help
Post by: Dr_Alio on February 12, 2017, 17:16
CarlJohnson I had to update all includes and plugins and than it worked :D
Title: Re: Need scripting help
Post by: Doc. on February 12, 2017, 17:19
Quote from: Dr_Alio on February 12, 2017, 17:16
CarlJohnson I had to update all includes and plugins and than it worked :D
^^ Great job, without u or carl i would have never figured out this whole test server thing
Title: Re: Need scripting help
Post by: Ethan on February 12, 2017, 20:22
Quote from: DOC on February 12, 2017, 17:19
without u or carl i would have never figured out this whole test server thing
and to think I cant get mine to work after two years of having it
Title: Re: Need scripting help
Post by: Martin on February 13, 2017, 04:57
Quote from: Ethan on February 12, 2017, 20:22
Quote from: DOC on February 12, 2017, 17:19
without u or carl i would have never figured out this whole test server thing
and to think I cant get mine to work after two years of having it

:biggrin:
Title: Re: Need scripting help
Post by: Dobby on February 13, 2017, 05:22
SA:MP scripting is one of the easiest things to learn. Message me on Steam if you like Ethan.