Car problem.
#1

PHP код:
/*
=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~
=~==~=~==COPYRIGHT - 2012 - LYNET=~==~=~==~=~==~=~==~=~==~
*/
#include <a_samp>
#include <zcmd>
#include <foreach>
#include <sscanf2>
// Colors
#define COLOR_BRIGHTRED 0xFF000AAA
#define COLOR_AQUA 0x00FFFFAA
#define COLOR_GREYs 0xAFAFAFAA
#define COLOR_BEIGE 0xFFF8DCAA
#define COLOR_BLACK 0x000000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_BLUELIGHTER 0x00BFFFAA
#define COLOR_BLUELIGHT 0x1E90FFAA
#define COLOR_BLUEMEDIUM 0x0000CDAA
#define COLOR_BLUEDARK 0x00008BAA
#define COLOR_PINK 0xFF1493AA
#define COLOR_PINKDARK 0xFF00FFAA
#define COLOR_FADE 0xE6E6E6E6
#define COLOR_GREEN 0x008000AA
#define COLOR_GREENLIGHT 0x00FF00AA
#define COLOR_GREENDARK 0x006400AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OKER 0x808000AA
#define COLOR_ORANGE 0xFF4500AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_VIOLETDARK 0x9400D3AA
#define COLOR_INDIGO 0xAB0082AA
#define COLOR_RED 0xFF0000AA
#define COLOR_SAND 0xFFDEADAA
#define COLOR_SILVER 0xC0C0C0AA
#define COLOR_TEAL 0x008080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GOLD 0xFFD700AA
#define COLOR_BROWN 0x8B4513AA
#define COLOR_BROWNLIGHT 0xA0522DAA
#define COLOR_GRAY 0xA9A9A9AA
#define COLOR_GRAYDARK 0x696969AA
#define COLOR_INVISIBLE 0xFFFFFF00
#define COLOR_GREY 0xBEBEBEAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREENs 0x33AA33AA
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED1 0xFF0000AA
#define COLOR_LIGHTGREEN 0x9ACD32AA
#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(
" LNS v1.0a");
    print(
"----------------------------------\n");
}
#endif
public OnGameModeInit()
{
  
SetGameModeText("Live 'N' Scream");
  
AddPlayerClass(107,2519.5652,-1673.0038,14.5379,80.2884,0,0,0,0,0,0); // GroveS1
  
AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
  
return 1;
}
public 
OnGameModeExit()
{
return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
SendClientMessage(playeridCOLOR_YELLOW"SERVER: /modhelp -> /admins -> /updates");
    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleid)
{
   if(
vehicleid == 412)
   {
      new 
name[MAX_PLAYER_NAME+1];
      
GetPlayerName(playeridname,sizeof(name));
      if(
strfind(name,"[GS]",false) != -1);
      }
      else
      {
         
SendClientMessage(playeridCOLOR_GREEN,"SERVER: You are not a official Grove Street Member!");
         
RemovePlayerFromVehicle(playerid);
      }
   }
   return 
1;

Look i got this, no errors, but the script have NO effect on the car ID 412.

Someone please help me.
Reply
#2

Dude you put the model of the car

right here at red mark

Код:
AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
use like this:

pawn Код:
new thevehicle;

public OnGameModeInit()
{
  SetGameModeText("Live 'N' Scream");
  AddPlayerClass(107,2519.5652,-1673.0038,14.5379,80.2884,0,0,0,0,0,0); // GroveS1
  thevehicle = AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
  return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /modhelp -> /admins -> /updates");
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid)
{
   if(vehicleid == thevehicle)
   {
      new name[MAX_PLAYER_NAME+1];
      GetPlayerName(playerid, name,sizeof(name));
      if(strfind(name,"[GS]",false) != -1);
      }
      else
      {
         SendClientMessage(playerid, COLOR_GREEN,"SERVER: You are not a official Grove Street Member!");
         RemovePlayerFromVehicle(playerid);
      }
   }
   return 1;
}
Reply
#3

still not :/

no errors, but the script dont work IG.
Reply
#4

i think you done wrong with strfind try to get more information about strfind ****** it "strfind samp"
Reply
#5

You can't remove players from vehicles under OnPlayerEnterVehicle, you need to use OnPlayerStateChange like this
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)) // Player entered a vehicle
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 412)
        {
            new name[MAX_PLAYER_NAME+1];
            GetPlayerName(playerid, name,sizeof(name));
            if(strfind(name,"[GS]",false) != -1)
            {
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREEN,"SERVER: You are not a official Grove Street Member!");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}
Reply
#6

still not
Reply
#7

try this...

pawn Код:
/*
=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~
=~==~=~==COPYRIGHT - 2012 - LYNET=~==~=~==~=~==~=~==~=~==~
*/


#include <a_samp>
#include <zcmd>
#include <foreach>
#include <sscanf2>


// Colors
#define COLOR_BRIGHTRED 0xFF000AAA
#define COLOR_AQUA 0x00FFFFAA
#define COLOR_GREYs 0xAFAFAFAA
#define COLOR_BEIGE 0xFFF8DCAA
#define COLOR_BLACK 0x000000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_BLUELIGHTER 0x00BFFFAA
#define COLOR_BLUELIGHT 0x1E90FFAA
#define COLOR_BLUEMEDIUM 0x0000CDAA
#define COLOR_BLUEDARK 0x00008BAA
#define COLOR_PINK 0xFF1493AA
#define COLOR_PINKDARK 0xFF00FFAA
#define COLOR_FADE 0xE6E6E6E6
#define COLOR_GREEN 0x008000AA
#define COLOR_GREENLIGHT 0x00FF00AA
#define COLOR_GREENDARK 0x006400AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OKER 0x808000AA
#define COLOR_ORANGE 0xFF4500AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_VIOLETDARK 0x9400D3AA
#define COLOR_INDIGO 0xAB0082AA
#define COLOR_RED 0xFF0000AA
#define COLOR_SAND 0xFFDEADAA
#define COLOR_SILVER 0xC0C0C0AA
#define COLOR_TEAL 0x008080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GOLD 0xFFD700AA
#define COLOR_BROWN 0x8B4513AA
#define COLOR_BROWNLIGHT 0xA0522DAA
#define COLOR_GRAY 0xA9A9A9AA
#define COLOR_GRAYDARK 0x696969AA
#define COLOR_INVISIBLE 0xFFFFFF00
#define COLOR_GREY 0xBEBEBEAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREENs 0x33AA33AA
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED1 0xFF0000AA
#define COLOR_LIGHTGREEN 0x9ACD32AA


#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(" LNS v1.0a");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
  SetGameModeText("Live 'N' Scream");
  AddPlayerClass(107,2519.5652,-1673.0038,14.5379,80.2884,0,0,0,0,0,0); // GroveS1
  new grovecar = AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
  return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /modhelp -> /admins -> /updates");
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid)
{
   if(vehicleid == grovecar)
   {
      new name[MAX_PLAYER_NAME+1], tmp[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name,sizeof(name));
      if(!sscanf("name", "'['s']'", tmp));
      else if(strcmp(tmp, "GS", false, strlen("GS")) != 0);
      else
      {
          new x, y, z;
         SendClientMessage(playerid, COLOR_GREEN,"SERVER: You are not an official Grove Street Member!");
         GetPlayerPos(playerid, x, y, z);
         SetPlayerPos(playerid, x, y, z);
      }
   }
   return 1;
Reply
#8

Quote:
Originally Posted by deb014
Посмотреть сообщение
try this...

pawn Код:
/*
=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~
=~==~=~==COPYRIGHT - 2012 - LYNET=~==~=~==~=~==~=~==~=~==~
*/


#include <a_samp>
#include <zcmd>
#include <foreach>
#include <sscanf2>


// Colors
#define COLOR_BRIGHTRED 0xFF000AAA
#define COLOR_AQUA 0x00FFFFAA
#define COLOR_GREYs 0xAFAFAFAA
#define COLOR_BEIGE 0xFFF8DCAA
#define COLOR_BLACK 0x000000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_BLUELIGHTER 0x00BFFFAA
#define COLOR_BLUELIGHT 0x1E90FFAA
#define COLOR_BLUEMEDIUM 0x0000CDAA
#define COLOR_BLUEDARK 0x00008BAA
#define COLOR_PINK 0xFF1493AA
#define COLOR_PINKDARK 0xFF00FFAA
#define COLOR_FADE 0xE6E6E6E6
#define COLOR_GREEN 0x008000AA
#define COLOR_GREENLIGHT 0x00FF00AA
#define COLOR_GREENDARK 0x006400AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OKER 0x808000AA
#define COLOR_ORANGE 0xFF4500AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_VIOLETDARK 0x9400D3AA
#define COLOR_INDIGO 0xAB0082AA
#define COLOR_RED 0xFF0000AA
#define COLOR_SAND 0xFFDEADAA
#define COLOR_SILVER 0xC0C0C0AA
#define COLOR_TEAL 0x008080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GOLD 0xFFD700AA
#define COLOR_BROWN 0x8B4513AA
#define COLOR_BROWNLIGHT 0xA0522DAA
#define COLOR_GRAY 0xA9A9A9AA
#define COLOR_GRAYDARK 0x696969AA
#define COLOR_INVISIBLE 0xFFFFFF00
#define COLOR_GREY 0xBEBEBEAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREENs 0x33AA33AA
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED1 0xFF0000AA
#define COLOR_LIGHTGREEN 0x9ACD32AA


#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(" LNS v1.0a");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
  SetGameModeText("Live 'N' Scream");
  AddPlayerClass(107,2519.5652,-1673.0038,14.5379,80.2884,0,0,0,0,0,0); // GroveS1
  new grovecar = AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
  return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /modhelp -> /admins -> /updates");
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid)
{
   if(vehicleid == grovecar)
   {
      new name[MAX_PLAYER_NAME+1], tmp[MAX_PLAYER_NAME];
      GetPlayerName(playerid, name,sizeof(name));
      if(!sscanf("name", "'['s']'", tmp));
      else if(strcmp(tmp, "GS", false, strlen("GS")) != 0);
      else
      {
          new x, y, z;
         SendClientMessage(playerid, COLOR_GREEN,"SERVER: You are not an official Grove Street Member!");
         GetPlayerPos(playerid, x, y, z);
         SetPlayerPos(playerid, x, y, z);
      }
   }
   return 1;
grovecar should be a global variable. As a user said, it should be in OnPlayerStateChange.
Reply
#9

pawn Код:
/*
=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~=~==~
=~==~=~==COPYRIGHT - 2012 - LYNET=~==~=~==~=~==~=~==~=~==~
*/


#include <a_samp>
#include <zcmd>
#include <foreach>
#include <sscanf2>


// Colors
#define COLOR_BRIGHTRED 0xFF000AAA
#define COLOR_AQUA 0x00FFFFAA
#define COLOR_GREYs 0xAFAFAFAA
#define COLOR_BEIGE 0xFFF8DCAA
#define COLOR_BLACK 0x000000AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_BLUELIGHTER 0x00BFFFAA
#define COLOR_BLUELIGHT 0x1E90FFAA
#define COLOR_BLUEMEDIUM 0x0000CDAA
#define COLOR_BLUEDARK 0x00008BAA
#define COLOR_PINK 0xFF1493AA
#define COLOR_PINKDARK 0xFF00FFAA
#define COLOR_FADE 0xE6E6E6E6
#define COLOR_GREEN 0x008000AA
#define COLOR_GREENLIGHT 0x00FF00AA
#define COLOR_GREENDARK 0x006400AA
#define COLOR_MAROON 0x800000AA
#define COLOR_OKER 0x808000AA
#define COLOR_ORANGE 0xFF4500AA
#define COLOR_PURPLE 0x800080AA
#define COLOR_VIOLETDARK 0x9400D3AA
#define COLOR_INDIGO 0xAB0082AA
#define COLOR_RED 0xFF0000AA
#define COLOR_SAND 0xFFDEADAA
#define COLOR_SILVER 0xC0C0C0AA
#define COLOR_TEAL 0x008080AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GOLD 0xFFD700AA
#define COLOR_BROWN 0x8B4513AA
#define COLOR_BROWNLIGHT 0xA0522DAA
#define COLOR_GRAY 0xA9A9A9AA
#define COLOR_GRAYDARK 0x696969AA
#define COLOR_INVISIBLE 0xFFFFFF00
#define COLOR_GREY 0xBEBEBEAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREENs 0x33AA33AA
#define COLOR_GRAD5 0xE3E3E3FF
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_RED1 0xFF0000AA
#define COLOR_LIGHTGREEN 0x9ACD32AA


#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(" LNS v1.0a");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
  SetGameModeText("Live 'N' Scream");
  AddPlayerClass(107,2519.5652,-1673.0038,14.5379,80.2884,0,0,0,0,0,0); // GroveS1
  AddStaticVehicle(412,2511.3474,-1688.5330,13.3903,230.1526,10,8); // GroveC1
  return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /modhelp -> /admins -> /updates");
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid)
{
   if(GetVehicleModel(vehicleid) == 412)
   {
      new name[MAX_PLAYER_NAME+1];
      GetPlayerName(playerid, name,sizeof(name));
      if(strfind(name,"[GS]",false) != -1) { //if you don't want to do anything here. leave it blank.
      }
      else
      {
         SendClientMessage(playerid, COLOR_GREEN,"SERVER: You are not a official Grove Street Member!");
         RemovePlayerFromVehicle(playerid);
      }
   }
   return 1;
}
Use above ^

he actually wants to restrict player entering vehicle model id 412. but here we used only "vehicleid" not "GetVehicleModel(vehicleid)" which will get the vehicle's model of the vehicle id in which player entered ^^
Reply
#10

Quote:
Originally Posted by Dwane
Посмотреть сообщение
grovecar should be a global variable. As a user said, it should be in OnPlayerStateChange.
lol, that's true, now I am feeling a lot of shame, however, that's the idea, and someone can copy that code and define the variable after defines and before main() and initialize at the car creation into OnGameModeInit.

And of course you can use OnPlayerEnterVehicle, the only thing you have to do is force the player to stay out the car instead of removing from it.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)