SA-MP Forums Archive
How to improve my command - 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: How to improve my command (/showthread.php?tid=441402)



How to improve my command - rhds - 02.06.2013

Can you look trough my command and tell me why if I'm alone in the server it still allows me to execute the command and also sometimes it doubles the text with virtual worlds?

pawn Код:
CMD:course(playerid, params[])
{
    new id, string[128], course, rand = random(1000);
    if(sscanf(params, "ui", id, course))
    {
        SendClientMessage(playerid, White, "Use: /course [playerid] [course ID]");
        SendClientMessage(playerid, White, "Courses: ID:1 - Stop course, ID:2 - Driving 1");
    }
    if(course > 2) SendClientMessage(playerid, White, "There are only 2 courses yet.");
    if(id == INVALID_PLAYER_ID && course == 1 && course <= 2)
    {
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerVirtualWorld(id, 0);
        SendClientMessage(playerid, White, "Your virtual world was set to 0, and course stopped.");
        SendClientMessage(id, White, "Your virtual world was set to 0, and course stopped.");
    }
    if(id != INVALID_PLAYER_ID && course == 2 && course <= 2)
    {
        SetPlayerVirtualWorld(playerid, rand);
        SetPlayerVirtualWorld(id, rand);
        format(string, sizeof(string), "Your virtual world was set to %d, and 'Driving 1' course started.", rand);
        SendClientMessage(playerid, White, string);
        SendClientMessage(id, White, string);
        SetVehicleVirtualWorld(AddStaticVehicle(566, 1777.1274, -1908.1166, 13.3872, 270, 0, 0), rand);
        SetVehicleVirtualWorld(AddStaticVehicle(596, 1785.6792, -1908.1118, 13.1205, 270, 0, 0), rand);
    }
    return 1;
}



Re: How to improve my command - RenSoprano - 02.06.2013

pawn Код:
CMD:course(playerid, params[])
{
    new id, string[128], course, rand = random(1000);
    if(sscanf(params, "ui", id, course))
    {
        SendClientMessage(playerid, White, "Use: /course [playerid] [course ID]");
        SendClientMessage(playerid, White, "Courses: ID:1 - Stop course, ID:2 - Driving 1");
    }
    if(course > 2) SendClientMessage(playerid, White, "There are only 2 courses yet.");
    if(id == INVALID_PLAYER_ID && course == 1 && course <= 2)
    {
        SetPlayerVirtualWorld(id, 0);
        SendClientMessage(id, White, "Your virtual world was set to 0, and course stopped.");
    }
    if(id != INVALID_PLAYER_ID && course == 2 && course <= 2)
    {
        SetPlayerVirtualWorld(playerid, rand);
        SetPlayerVirtualWorld(id, rand);
        format(string, sizeof(string), "Your virtual world was set to %d, and 'Driving 1' course started.", rand);
        SendClientMessage(playerid, White, string);
        SendClientMessage(id, White, string);
        SetVehicleVirtualWorld(AddStaticVehicle(566, 1777.1274, -1908.1166, 13.3872, 270, 0, 0), rand);
        SetVehicleVirtualWorld(AddStaticVehicle(596, 1785.6792, -1908.1118, 13.1205, 270, 0, 0), rand);
    }
    return 1;
}
Now it won't double anymore