Can't Login now...
#1

I've been trying to learn how to script and I'm trying to implement scripts on this forum to see what they do and to see how they worked.

I've been trying to get a cone script I found here to work with The GF script...

Quote:

//---------------------------<[ OnPlayerCommandText ]>--------------------------------------------------------
new AmmountOfCones;

enum PlayerCones {
Cone1,
Cone2,
Cone3,
Cone4,
Cones
}
new PlayerConeCounter[MAX_PLAYERS][PlayerCones];

public OnPlayerCommandText(playerid, cmdtext[]) {
if ( !strcmp(cmdtext, "/Cone", true) ) {
if ( AmmountOfCones == MAX_CONES ) return SendClientMessage(playerid, COLOR_RED, "((Server Cone Limit Reached))");
if ( PlayerConeCounter[playerid][Cones] == 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);
if ( PlayerConeCounter[playerid][Cone1] == 0 ) {
PlayerConeCounter[playerid][Cone1] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
AmmountOfCones++;
PlayerConeCounter[playerid][Cones] += 1;
} else {
if ( PlayerConeCounter[playerid][Cone2] == 0 ) {
PlayerConeCounter[playerid][Cone2] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
AmmountOfCones++;
PlayerConeCounter[playerid][Cones] += 1;
} else {
if ( PlayerConeCounter[playerid][Cone3] == 0 ) {
PlayerConeCounter[playerid][Cone3] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
AmmountOfCones++;
PlayerConeCounter[playerid][Cones] += 1;
} else {
if ( PlayerConeCounter[playerid][Cone4] == 0 ) {
PlayerConeCounter[playerid][Cone4] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
AmmountOfCones++;
PlayerConeCounter[playerid][Cones] += 1;
}
}
}
}
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 <= PlayerConeCounter[playerid][Cones]; i++ ) {
if ( PlayerConeCounter[playerid][Cones] == 1 ) {
DestroyObject(PlayerConeCounter[playerid][Cone1]);
AmmountOfCones -= 1;
} else if ( PlayerConeCounter[playerid][Cones] == 2 ) {
DestroyObject(PlayerConeCounter[playerid][Cone1]);
DestroyObject(PlayerConeCounter[playerid][Cone2]);
AmmountOfCones -= 2;
} else if ( PlayerConeCounter[playerid][Cones] == 3 ) {
DestroyObject(PlayerConeCounter[playerid][Cone1]);
DestroyObject(PlayerConeCounter[playerid][Cone2]);
DestroyObject(PlayerConeCounter[playerid][Cone3]);
AmmountOfCones -= 3;
} else if ( PlayerConeCounter[playerid][Cones] == 4 ) {
DestroyObject(PlayerConeCounter[playerid][Cone1]);
DestroyObject(PlayerConeCounter[playerid][Cone2]);
DestroyObject(PlayerConeCounter[playerid][Cone3]);
DestroyObject(PlayerConeCounter[playerid][Cone4]);
AmmountOfCones -= 4;
}
PlayerConeCounter[playerid][Cone1] = 0;
PlayerConeCounter[playerid][Cone2] = 0;
PlayerConeCounter[playerid][Cone3] = 0;
PlayerConeCounter[playerid][Cone4] = 0;
PlayerConeCounter[playerid][Cones] = 0;
}
return SendClientMessage(playerid, COLOR_GREEN, "You have picked your cones up.");
}

if ( !strcmp(cmdtext, "/RemoveConesAll", true) ) {
if ( IsPlayerAdmin(playerid) ) {
for ( new i = 0; i <= MAX_PLAYERS; i++ ) {
DestroyObject(PlayerConeCounter[playerid][Cone1]);
DestroyObject(PlayerConeCounter[playerid][Cone2]);
DestroyObject(PlayerConeCounter[playerid][Cone3]);
DestroyObject(PlayerConeCounter[playerid][Cone4]);
PlayerConeCounter[playerid][Cone1] = 0;
PlayerConeCounter[playerid][Cone2] = 0;
PlayerConeCounter[playerid][Cone3] = 0;
PlayerConeCounter[playerid][Cone4] = 0;
PlayerConeCounter[playerid][Cones] = 0;
AmmountOfCones = 0;
}
return SendClientMessage(playerid, COLOR_GREEN, "*ADMIN*- You have removed all the cones.");
}
}
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new cmd[256];
new tmp[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
return 0;

I get a warning and for some reason now the /login and /register cmds say that they are unknown cmds

Quote:

C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\gf.pwn(822 : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Header size: 5984 bytes
Code size: 1104696 bytes
Data size: 2193772 bytes
Stack/heap size: 16384 bytes; estimated max. usage=4904 cells (19616 bytes)
Total requirements: 3320836 bytes

1 Warning.

Reply
#2

wat code is between line 8228?
Reply
#3

if(strcmp(cmd, "/pay", true) == 0)

that's right after what I put in the quotes
Reply
#4

This may or may not work. If it does not, then you must post your entire OnPlayerCommandText function.

The problem is that you returned a value before "/login" and "/register" can be identified by strcmp.
When you return a value, it basically tells your function to stop what it's doing and exit.
So that makes the code below the "return 0;" (line 822 in the OnPlayerCommandText function unreachable.

Simply erasing the "return 0;" at the end of your posted code should solve the problem.

pawn Код:
//---------------------------<[ OnPlayerCommandText ]>--------------------------------------------------------
  new AmmountOfCones;

  enum PlayerCones {
  Cone1,
  Cone2,
  Cone3,
  Cone4,
  Cones
}
  new PlayerConeCounter[MAX_PLAYERS][PlayerCones];

public OnPlayerCommandText(playerid, cmdtext[]) {
  if ( !strcmp(cmdtext, "/Cone", true) ) {
   if ( AmmountOfCones == MAX_CONES ) return SendClientMessage(playerid, COLOR_RED, "((Server Cone Limit Reached))");
    if ( PlayerConeCounter[playerid][Cones] == 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);
   if ( PlayerConeCounter[playerid][Cone1] == 0 ) {
     PlayerConeCounter[playerid][Cone1] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
     AmmountOfCones++;
     PlayerConeCounter[playerid][Cones] += 1;
   } else {
      if ( PlayerConeCounter[playerid][Cone2] == 0 ) {
      PlayerConeCounter[playerid][Cone2] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
      AmmountOfCones++;
      PlayerConeCounter[playerid][Cones] += 1;
      } else {
       if ( PlayerConeCounter[playerid][Cone3] == 0 ) {
        PlayerConeCounter[playerid][Cone3] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
        AmmountOfCones++;
        PlayerConeCounter[playerid][Cones] += 1;
      } else {
        if ( PlayerConeCounter[playerid][Cone4] == 0 ) {
         PlayerConeCounter[playerid][Cone4] = CreateObject(1238, X, Y, Z-0.7, 0.0, 0.0, A);
         AmmountOfCones++;
         PlayerConeCounter[playerid][Cones] += 1;
        }
      }
      }
   }
   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 <= PlayerConeCounter[playerid][Cones]; i++ ) {
     if ( PlayerConeCounter[playerid][Cones] == 1 ) {
       DestroyObject(PlayerConeCounter[playerid][Cone1]);
       AmmountOfCones  -= 1;
     } else if ( PlayerConeCounter[playerid][Cones] == 2 ) {
       DestroyObject(PlayerConeCounter[playerid][Cone1]);
       DestroyObject(PlayerConeCounter[playerid][Cone2]);
       AmmountOfCones  -= 2;
     } else if ( PlayerConeCounter[playerid][Cones] == 3 ) {
       DestroyObject(PlayerConeCounter[playerid][Cone1]);
       DestroyObject(PlayerConeCounter[playerid][Cone2]);
       DestroyObject(PlayerConeCounter[playerid][Cone3]);
       AmmountOfCones  -= 3;
     } else if ( PlayerConeCounter[playerid][Cones] == 4 ) {
       DestroyObject(PlayerConeCounter[playerid][Cone1]);
       DestroyObject(PlayerConeCounter[playerid][Cone2]);
       DestroyObject(PlayerConeCounter[playerid][Cone3]);
       DestroyObject(PlayerConeCounter[playerid][Cone4]);
       AmmountOfCones  -= 4;
     }
     PlayerConeCounter[playerid][Cone1]  = 0;
     PlayerConeCounter[playerid][Cone2]  = 0;
     PlayerConeCounter[playerid][Cone3]  = 0;
     PlayerConeCounter[playerid][Cone4]  = 0;
     PlayerConeCounter[playerid][Cones]  = 0;
   }
   return SendClientMessage(playerid, COLOR_GREEN, "You have picked your cones up.");
  }

  if ( !strcmp(cmdtext, "/RemoveConesAll", true) ) {
    if ( IsPlayerAdmin(playerid) ) {
     for ( new i = 0; i <= MAX_PLAYERS; i++ ) {
      DestroyObject(PlayerConeCounter[playerid][Cone1]);
      DestroyObject(PlayerConeCounter[playerid][Cone2]);
      DestroyObject(PlayerConeCounter[playerid][Cone3]);
      DestroyObject(PlayerConeCounter[playerid][Cone4]);
      PlayerConeCounter[playerid][Cone1]  = 0;
      PlayerConeCounter[playerid][Cone2]  = 0;
      PlayerConeCounter[playerid][Cone3]  = 0;
      PlayerConeCounter[playerid][Cone4]  = 0;
      PlayerConeCounter[playerid][Cones]  = 0;
       AmmountOfCones           = 0;
     }
     return SendClientMessage(playerid, COLOR_GREEN, "*ADMIN*- You have removed all the cones.");
    }
  }
  new string[256];
  new playermoney;
  new sendername[MAX_PLAYER_NAME];
  new giveplayer[MAX_PLAYER_NAME];
  new playername[MAX_PLAYER_NAME];
  new cmd[256];
  new tmp[256];
  new giveplayerid, moneys, idx;
  cmd = strtok(cmdtext, idx);
Reply
#5

THANKS !!

That worked, now while I have you here...

I want to put an icon object in front of an interior, I've been looking and people are saying to use.....

objectid = CreateObject( 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );

I found that in the wiki for sa-mp, Would I just put in the object id for the icon I want and the co-ords ? Would I be able to just place that anywhere in the script ? Also to get the right co-ords would I use /save ?
Reply
#6

move this code to the top of public OnPlayerCommandText(playerid, cmdtext[]){ like this..

Код:
OnPlayerCommandText(playerid, cmdtext[]){
  new string[256]
  new playermoney;
  new sendername[MAX_PLAYER_NAME];
  new giveplayer[MAX_PLAYER_NAME];
  new playername[MAX_PLAYER_NAME];
  new cmd[256];
  new tmp[256];
  new giveplayerid, moneys, idx;
  cmd = strtok(cmdtext, idx);
then try removing return0; and put
Код:
return 1;}
Reply
#7

Quote:
Originally Posted by Ace_Steele
THANKS !!

That worked, now while I have you here...

I want to put an icon object in front of an interior, I've been looking and people are saying to use.....

objectid = CreateObject( 2587, 2001.195679, 1547.113892, 14.283400, 0, 0, 96 );

I found that in the wiki for sa-mp, Would I just put in the object id for the icon I want and the co-ords ? Would I be able to just place that anywhere in the script ? Also to get the right co-ords would I use /save ?
Well CreateObject is for creating objects like ramps and stuff you generally see built on stunt servers.

To create an icon, or 'pickup' you use CreatePickup.
CreatePickup can make those floating 'i' icons you see all the time on Roleplay servers.

More info here:
https://sampwiki.blast.hk/wiki/CreatePickup
Reply
#8

// Create a pickup for armor.
new pickup;
pickup = CreatePickup ( 1242, 2, 1503.3359, 1432.3585, 10.1191 );

//some time later...
DestroyPickup(pickup);

this is the sample from the wiki...

Where would I place this ?

Would I get the co-ords by doing /save ?

I have the co-ords but not sure where to put them...
Reply
#9

https://sampwiki.blast.hk/w/index.php?ti...&printable=yes
Reply
#10

Quote:
Originally Posted by troy52192
I saw that but I want to know if /save is the best way to get the co-ords
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)