SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 17/01/2010, 03:41 PM   #1
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default strtok causing problems?

I am trying to load 4 seperate filterscripts with a stock strtok in each but the final one i load doesnt work

i get no errors, all compiled successfully, all scripts run fine until they are all loaded.

they all use the onplayercommandtext bit

what am i missing?
adsy is offline  
Old 17/01/2010, 03:42 PM   #2
pagie1111
Huge Clucker
 
Join Date: Dec 2008
Posts: 463
Reputation: 20
Default Re: strtok causing problems?

Please show the command
__________________
Have just returned to SA:MP as of 21/07/2015
Will be reviewing one of my old scripts and releasing a new version!
+1 rep

________________________________________________
pagie1111 is offline  
Old 17/01/2010, 03:51 PM   #3
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default Re: strtok causing problems?

well i think its down to my invalids filterscript.

ill post that one:

Code:
#define FILTERSCRIPT
#include <a_samp>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
stock strtok(const string[], &index)
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= ' '))
  {
   index++;
  }

  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  {
   result[index - offset] = string[index];
   index++;
  }
  result[index - offset] = EOS;
  return result;
}
new playercash;
new InvalidNosVehicles[30] =
{
  581,523,462,521,463,522,461,448,468,586,
  509,481,510,472,473,493,595,484,430,453,
  452,446,454,590,569,537,538,539,570,449
};
new InvalidSellVehicles[21] =
{
  592,537,538,449,435,450,524,528,553,569,
  570,584,590,591,592,601,606,607,608,610,
  611
};
forward IsPlayerInInvalidNosVehicle(playerid);
forward IsPlayerInInvalidSellVehicle(playerid);

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("---Invalids Filterscript (Sell/Nos)---");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public IsPlayerInInvalidNosVehicle(playerid)
{
  new carid = GetPlayerVehicleID(playerid);
  new carmodel = GetVehicleModel(carid);
  for (new i=0; i<sizeof(InvalidNosVehicles); i++) {
    if (carmodel == InvalidNosVehicles[i]) return 1;
  }
  return 0;
}


public IsPlayerInInvalidSellVehicle(playerid)
{
  new carid = GetPlayerVehicleID(playerid);
  new carmodel = GetVehicleModel(carid);
  for (new i=0; i<sizeof(InvalidSellVehicles); i++) {
    if (carmodel == InvalidSellVehicles[i]) return 1;
  }
  return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  new string[256];
  new cmd[256];
  new idx;

  cmd = strtok(cmdtext, idx);
  if(strcmp(cmdtext, "/sell", true) == 0) {
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) != 0) {
      SendClientMessage(playerid, 0xFFFFFFFF, "You are not driving this vehicle!");
    }
    if(!IsPlayerInAnyVehicle(playerid)) {
      SendClientMessage(playerid, 0xFFFFFFFF, "Your not in a vehicle!");
    }
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0) {

      new carvalue;
      new carvaluedamaged1;
      new carvaluedamaged2;
      new currentveh;
      new Float:health;

      currentveh = GetPlayerVehicleID(playerid);

      GetVehicleHealth(currentveh, health);
      carvaluedamaged1 = random(2500);
      carvaluedamaged2 = random(900);

      if(health == 1000) {
        carvalue = random(5000);
      }
      else if (health >999) {
        carvalue = carvaluedamaged1;
      }
      else if (health >550) {
        carvalue = carvaluedamaged2;
      }
      if(!IsPlayerInInvalidSellVehicle(playerid)) {
        DestroyVehicle(currentveh);
        format(string, sizeof(string), "You get %i for your vehicle!", carvalue);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        GivePlayerMoney(playerid, carvalue);
      }
      else {
        SendClientMessage(playerid, 0xFFFFFFFF, "This vehicle can't be sold!");
      }

    }
    return 1;
  }
  if(strcmp(cmd, "/nos", true) == 0) {

    playercash = GetPlayerMoney(playerid);

    if (IsPlayerInAnyVehicle(playerid)) {
      if(!IsPlayerInInvalidNosVehicle(playerid)) {
        if(playercash > 50) {
                         // Nitro
          AddVehicleComponent(GetPlayerVehicleID(playerid), 1009);
          SendClientMessage(playerid, 0xFFFFFFAA, "Nitro added.");
          GivePlayerMoney(playerid, -50);
        }
        else {
          SendClientMessage(playerid, 0xFFFFFFAA, "You need more money.");
        }
      }
      else {
        SendClientMessage(playerid, 0xFFFFFFAA, "Put your money away, this vehicle cant have nitrous.");
      }
    }
    else {
      SendClientMessage(playerid, 0xFFFFFFAA, "Your not in a car.");
    }
    return 1;
  }
  return 1;
}
adsy is offline  
Old 17/01/2010, 04:07 PM   #4
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default Re: strtok causing problems?

im just gonna stick that bit back in the gamemode rather than mess around
adsy is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STRTOK problems selten98 Help Archive 18 28/05/2010 10:52 PM
Im stumped, can someone please tell me whats causing it.. chaosnz Help Archive 0 26/04/2010 05:19 AM
What could be causing this ihatetn931 Help Archive 9 13/02/2010 07:27 AM
Smakkie mod causing sa-mp not to work! rico760 Client Support 4 02/04/2009 11:31 AM
SA:MP causing odd problems Blizz Client Support 2 02/03/2009 11:09 PM


All times are GMT. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.