Help with setting a limit
#1

I'm new to scripting and started to make some basic commands, 1 thing i have a problem with is how to set a limit? for example with this:

Код:
	
	if (strcmp(cmd,"/roadblock",true) == 0)
	{
	    new Float:X,Float:Y,Float:Z,Float:A;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid,A);
        roadblock = CreateObject(978, X, Y, Z, 0.0, 0.0, A);
	    return 1;
	}
	if (strcmp(cmd,"/deleteblock",true) == 0)
	{
        DestroyObject(roadblock);
	    return 1;
	}
My problem here is that i can create unlimited roadblocks, but only delete 1 (like, i place 2 roadblocks, but i can only do /deleteblock once where it works) i thought that a limit could solve this, but i have no clue how to set a limit for placing objects, i searched around for long and didn't find anything, if anyone could help me i would be thankfull.

Another thing, if you know how to make it so i can use /deleteblock more than once that would be very great aswell, either where it just delete 1 roadblock at a time, or perhaps a /deleteallblocks which would delete all roadblocks.
Reply
#2

pawn Код:
//global variables
    new bool:Blocked[MAX_PLAYERS];
    new roadblock[MAX_PLAYERS];

    //commands
    if (strcmp(cmd,"/roadblock",true) == 0)
    {
        if(!Blocked[playerid])
        {
            new Float:X,Float:Y,Float:Z,Float:A;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid,A);
            roadblock[playerid] = CreateObject(978, X, Y, Z, 0.0, 0.0, A);
            Block[playerid] = true;
            return 1;
        }
        else return SendClientMessage(playerid, -1, "You already create a road block...delete first!");
    }
    if (strcmp(cmd,"/deleteblock",true) == 0)
    {
        if(Blocked[playerid])
        {
            DestroyObject(roadblock[playerid);
            Blocked[playerid] = false;
            return 1;
        }
        else return SendClientMessage(playerid, -1, "You dont create any road block!");
    }
Reply
#3

Thank you so much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)