Help with script error
#1

Hello, i'm new to scripting (started yesterday) and I have a problem. I'm trying to a make a strtok command and I keep getting this error when I compile.

#include <a_samp>
#define TEAM_GROVE 1
#define TEAM_BALLA 2
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple
#define strtok
new gTeam[MAX_PLAYERS];
new Menu:teleportmenu;
new value;
new tmp;
new cmd;






// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
teleportmenu = CreateMenu("Teleportmenu", 2, 200.0, 100.0, 150.0, 150.0);
AddMenuItem(teleportmenu, 0, "LS");
AddMenuItem(teleportmenu, 0, "LS");
AddMenuItem(teleportmenu, 0, "SF");
AddMenuItem(teleportmenu, 0, "SF");
AddMenuItem(teleportmenu, 0, "LV");
AddMenuItem(teleportmenu, 0, "LV");

AddMenuItem(teleportmenu, 1, "Grove Street");
AddMenuItem(teleportmenu, 1, "Starfish Tower");
AddMenuItem(teleportmenu, 1, "Wheel Arch Angels");
AddMenuItem(teleportmenu, 1, "Jizzys");
AddMenuItem(teleportmenu, 1, "4 Dragons");
AddMenuItem(teleportmenu, 1, "Come-a-Lot");
SetGameModeText("Blank Script");
AddStaticVehicle(560,1567.9526,-1010.7532,23.6129,2.6959,-1,-1);
AddPlayerClass(0, 1576.2999,-1023.2874, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
AddPlayerClass(102, 1576.2999,-1023.2874, 15.3746, 269.1425, 5, 0, 22, 100, 32, 50);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerTeamFromClass(playerid, classid);
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerPrivmsg(playerid, recieverid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
tmp[128]
cmd = strtok(cmdtext, value);
if(strcmp(cmd, "/setgravity", true) == 0);
{

tmp = strtok(cmdtext, value);

return 1;

}
if(strcmp(cmdtext, "/teleport", true) == 0)
{
ShowMenuForPlayer(teleportmenu,playerid);
return 1;
}
return 0;

}

Quote:

C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(53) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(65) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(80) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(104 ) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(134 ) : error 028: invalid subscript (not an array or too many subscripts): "tmp"
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(134 ) : warning 215: expression has no effect
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(134 ) : error 001: expected token: ";", but found "]"
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(134 ) : error 029: invalid expression, assumed zero
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(134 ) : fatal error 107: too many error messages on one line

You have an Idea what could be the problem?

Sory for the long post I don't know how to make spoilers
Reply
#2

wrong section
post this in "Scripting Disscusion"
too use a pawn code to your script,
Код:
pawn Код:
the script
Reply
#3

pawn Код:
tmp[128]
  cmd = strtok(cmdtext, value);
Reply
#4

First you defined tmp as integer on top of your script and then you defined it as a string at OnPlayerCommandText callback, and you also defined cmd as integer which should be string also.
Reply
#5

... I have a long way. Could you fix the error and then post? It would be really helpful if you will because I could learn from it.
Reply
#6

Just do this:
on top of your script, delete:
new tmp;
and change:
new cmd;
to:
new cmd[128];

And leave the existing tmp at OnPlayerCommandText callback.
Reply
#7

Thanks for clearning that up but now I have another problem.

I re defined the tmp[128] in the OnPlayerCommandText callback because I gotten an error saying that "tmp" was undefined.
The two errors I have problem now are the error on lines 135 and 139.

Quote:

C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(53) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(65) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(80) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(104 ) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(135 ) : error 033: array must be indexed (variable "cmd")
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(136 ) : error 036: empty statement
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(137 ) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(139 ) : error 033: array must be indexed (variable "tmp")
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(144 ) : warning 225: unreachable code
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(196 ) : warning 219: local variable "cmd" shadows a variable at a preceding level
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(218 ) : warning 217: loose indentation
C:\Program Files\GTA.San.Andreas\Server\gamemodes\new.pwn(260 ) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[128];
  cmd = strtok(cmdtext, value);
  if(strcmp(cmd, "/setgravity", true) == 0);
  {

   tmp = strtok(cmdtext, value);

   return 1;

  }


I tried following the tutorial on SA-MP wiki. Even when I copy the script itself most of the time I get the same errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)