AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Carmod Help (https://forums.alliedmods.net/showthread.php?t=27242)

Tykes 04-18-2006 03:38

Carmod Help
 
This is the part where you touch the car. (register_touch("item_car","player","setcar") )




Code:

public item_car() {
  new arg[33], arg2[33], itemstr[33], arg4[33]
  read_argv(1,arg,32)
  read_argv(2,arg2,32)
  read_argv(3,itemstr,32)
  read_argv(4,arg4,32)
  new id = str_to_num(arg)
  new itemid = str_to_num(arg2)
  speed[id] = str_to_num(arg4)
 
  if(incar[id] || carout[id]) {
      client_print(id,print_chat,"[CarMod] You've deleted your car.")
      set_item_amount(id,"+",itemid,1,"money")
      if(incar[id]) {
        new name[64]
        get_user_name(id,name,63)
        new message[300]
        format(message,299,"[CarMod] %s has turned off his engine and got out of the car.",name)
        overhear(id,300,message)
        client_cmd(id, "cl_forwardspeed %i;cl_sidespeed %i;cl_backwardspeed %i",oldspeed,oldspeed,oldspeed)
        set_user_info(id,"model",oldmodel[id])
        incar[id] = 0
      }
      if(carout[id]) {
        remove_entity(carout[id])
        set_item_amount(id,"+",itemid,1,"money")
      }
  }
  else {
      set_item_amount(id,"+",itemid,1,"money")
      if(allow[id] != 0) return PLUGIN_HANDLED
     
      new name[64]
      get_user_name(id,name,63)
      new message[300]
      format(message,299,"[CarMod] %s has gotten into his car and started the engine.",name)
      overhear(id,300,message)
      client_print(id,print_chat,"[CarMod] You have gotten into your car and started the engine.")
      get_user_info(id,"model",oldmodel[id], 32)
     
      carmodel[id] = itemstr
      set_user_info(id,"model",itemstr)
      client_cmd(id, "cl_forwardspeed %i;cl_sidespeed %i;cl_backwardspeed %i",speed[id],speed[id],speed[id])
     
      incar[id] = 1
      carout[id] = 0
      emit_sound(id, CHAN_ITEM, "carmod/start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) 
  }
  return PLUGIN_HANDLED
}

That is item_car.


This is setcar.


Code:

public setcar(entid,id) {
  if(allow[id] != 0) return PLUGIN_HANDLED
  if(incar[id] != 0) return PLUGIN_HANDLED
 
  new locked[33], authid[33]
  entity_get_string(entid,EV_SZ_target,locked,32)
  get_user_authid(id,authid,32)
  if(!equal(locked,"") || !equal(locked,authid)) return PLUGIN_HANDLED
  new name[64]
  get_user_name(id,name,63)
  new message[300]
  format(message,299,"[CarMod] %s has gotten into his car and started the engine.",name)
  overhear(id,300,message)
  client_print(id,print_chat,"[CarMod] You have gotten into your car and started the engine.")
  get_user_info(id,"model",oldmodel[id], 32)
 
  new itemstr[33]
  entity_get_string(entid,EV_SZ_targetname,itemstr,32)
 
  carmodel[id] = itemstring
  set_user_info(id,"model",itemstr)
  oldfric[id] = entity_get_float(id,EV_FL_friction)
  speed[id] = entity_get_int(id,EV_INT_team)
  client_cmd(id, "cl_forwardspeed %i;cl_sidespeed %i;cl_backwardspeed %i",speed[id],speed[id],speed[id])
  entity_set_float(id,EV_FL_friction,0.3)
 
  incar[id] = 1
  carout[id] = 0
  emit_sound(id, CHAN_ITEM, "carmod/start.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  remove_entity(entid)
  return PLUGIN_HANDLED
}





The problem is, in game, I can't get into the car.

Tykes 04-18-2006 23:08

bump


All times are GMT -4. The time now is 05:06.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.