Need Help/ I'm stuck.
#1

The script work to the extent of placing the cones, but im trying to make a limit for each player to place 4 cones each, problem is that once a player has placed 4 cones, and he removes them, he cannot place anymore cones( It says "You have no more cones"), and others get the Server Cone Limit reached, I got the Server Cone limit of 100 and the Player Cone limit of 4. Is there a reset command that resets it for the player?, Ive asked for advise to a more experienced scripter but hes stuck aswell.

If i need a database for it to work, I do have one.

Код:
if(!strcmp(cmdtext, "/cone", true))
		 {
               {
               if(gPlayerOnDuty[playerid] != 1)
                      {
			   SendClientMessage(playerid, COLOR_RED, "You need to be on duty.");
			   return 1;
		         }
               }
		 if(ConeCounter == MAX_CONES) return SendClientMessage(playerid, COLOR_RED, "((Server Cone Limit Reached))");
		 if(ConePCounter == MAX_PLAYER_CONES) return SendClientMessage(playerid, COLOR_RED, "You have no more cones");
		 new Float:X, Float:Y, Float:Z, Float:A;
		 GetPlayerPos(playerid, X, Y, Z);
		 GetPlayerFacingAngle(playerid, A);
		 Cone[ConeCounter++] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);
		 ConeP[ConePCounter++] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);
		 SetPlayerPos(playerid, X, Y, Z);
		 return SendClientMessage(playerid, COLOR_GREEN, "You have placed a cone.");
		 }


	 if(!strcmp(cmdtext, "/removecones", true))
     {
		 for(new i = 0; i <= ConeCounter; i++) DestroyObject(Cone[i]);
     ConePCounter = 4;
     return SendClientMessage(playerid, COLOR_GREEN, "You have picked your cones up.");
     }
     
   if(!strcmp(cmdtext, "/removeconesall", true))
    {
     for(new i = 0; i <= ConeCounter; i++) DestroyObject(Cone[i]);
     ConeCounter = 100;
     ConePCounter = 100;
     return SendClientMessage(playerid, COLOR_GREEN, "*ADMIN*- You have removed all the cones.");
     }
    }
Reply
#2

you are setting it to 4 and 100 when you should be putting it to 0
Reply
#3

I think youre calling ConeCounter++ 2 times, do something like thhat

pawn Код:
ConeConter++;
Cone[ConeCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);
ConeP[ConeCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);
i dont really know whether thhat helped but im just bit bored and tired
Reply
#4

Quote:
Originally Posted by Daren_Jacobson
you are setting it to 4 and 100 when you should be putting it to 0
I tried that but it ended up to not remove any of the cones, Played around with it aswell, and the number i set was the number of cones it removed. :/
Reply
#5

Or do you mean the MAX_CONES; and MAX_PLAYER_CONES; ? so it should be, MAX_CONES; 100 and MAX_PLAYER_CONES; 0 ?
Reply
#6

Quote:

ConeConter++;
Cone[ConeCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);
ConeP[ConeCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);

your creating to cones here ?

Quote:

ConeConter++;
Cone[ConeCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A+2);

Thats better :P

And

Quote:

ConeConter++;

Thats counting for every player make it

Quote:

ConeConter[playerid]++;

you will have to do that to all the ConeCounter integers,
and make

Quote:

new ConeCounter; || new ConeCounter = 0;

Into this

Quote:

ConeConter[MAX_PLAYERS]++;

and then each player should be able to make 4 cones each not 8
Reply
#7

Im making the player create 2 cones to limit the objects for the server, so that once MAX CONES reaches 100 no more cones will be allowed to be created, and an admin will have to remove the cones. I extracted everything in the script that has to do with the cones.

I made some of the changes you told, but I lost you at the later onces you told me to change.

Код:
#include <a_samp>
#define MAX_CONES 100
#define MAX_PLAYER_CONES 4
new Cone[MAX_CONES];
new ConeP[MAX_PLAYER_CONES];
new ConeCounter[MAX_PLAYERS];
new ConePCounter[MAX_PLAYER_CONES];

//*************************************** CONE COMMANDS ***********************************//
   	if(!strcmp(cmdtext, "/cone", true))
		 {
		 if(ConeCounter == MAX_CONES) return SendClientMessage(playerid, COLOR_RED, "((Server Cone Limit Reached))");
		 if(ConePCounter == MAX_PLAYER_CONES) return SendClientMessage(playerid, COLOR_RED, "You have no more cones");
		 new Float:X, Float:Y, Float:Z, Float:A;
		 GetPlayerPos(playerid, X, Y, Z);
		 GetPlayerFacingAngle(playerid, A);
		 ConeConter++;
    Cone[ConeCounter[MAX_PLAYERS]] = CreateObject(1238, X, Y, Z-2, 0.0, 0.0, A);
    Cone[ConePCounter] = CreateObject(1238, X, Y, Z-0.6, 0.0, 0.0, A);
		 SetPlayerPos(playerid, X, Y, Z);
		 return SendClientMessage(playerid, COLOR_GREEN, "You have placed a cone.");
		 }

    if(!strcmp(cmdtext, "/removecones", true))
    {
		 for(new i = 0; i <= ConeCounter; i++) DestroyObject(Cone[i]);
     ConePCounter = 4;
     return SendClientMessage(playerid, COLOR_GREEN, "You have picked your cones up.");
    }
    
    if(!strcmp(cmdtext, "/removeconesall", true))
    {
    if(!hasPermission(playerid, ADMIN)) { return 1; }
    {
		 for(new i = 0; i <= ConeCounter; i++) DestroyObject(Cone[i]);
     ConeCounter = 100;
     ConePCounter = 100;
     return SendClientMessage(playerid, COLOR_GREEN, "*ADMIN*- You have removed all the cones.");
    }
    }
Reply
#8

oo i messed the script up :/, Can you please tell me in more detail on wich onces to change, I got a little bit confused by the post you made :/. Really appreciate the help guys.
Reply
#9

Wow that was weird, i rewrote your whole cones script :P
only because i could not understand the one you wrote,

but here is one i just coded and it was tested no bugs found

Enjoy - JaYmE's Cone System

Let me know if you like it

EDIT - Do not edit ! if you want add credits,
and dont make it create 2 objects i have limited
they objects like you wanted
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)