I am working on making passenger mod for carmod (so sue me) and I have run into a few problems.
I want the effect to be when you type passenger (and are looking at a person inside a car), You are invisible, nocliped, and constantly teleported to their location +9 on the Z axis. When you type passenger again, you are teleported on their heads and stop the teleporting. This is what I have so far.
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
----------------------
public getin(id){
new blah2
if(get_user_aiming(id,carpool[id],blah2,200)) {
if(carpooled[id] == 1)
{
getout(id)
return PLUGIN_HANDLED;
}
if(incar[id] == 1){
if(carpooled[carpool[id]] == 1){
client_print(carpool[id],print_chat,"[CarMod] You got kicked out of the car!")
getout(carpool[id])
}else{
client_print(id,print_chat,"[CarMod] Get out of your car first!")
}
}
if(!is_user_connected(carpool[id]))
{
client_print(id,print_chat,"[CarMod] Invalid target.")
return PLUGIN_HANDLED;
}
if(incar[carpool[id]] == 0)
{
client_print(id,print_chat,"[CarMod] Player not in car.")
return PLUGIN_HANDLED;
}
client_print(id,print_chat,"[CarMod] You are now riding with the player!")
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,0)
set_user_noclip(id, 1)
get_user_origin(carpool[id], torigin[id])
torigin[id][2] += 80
carpooled[id] = 1
set_user_origin(id,torigin[id])
set_task(0.1, "originchange", id+45, "", 0, "b")
return PLUGIN_HANDLED
} else {
client_print(id,print_chat,"[CarMod] Too far away to ride the player's car.")
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED;
}
public originchange(id){
id -= 45
if(carpool[id] == 0)
{
getout(id)
remove_task(id+45)
return PLUGIN_HANDLED;
}
get_user_origin(carpool[id], torigin[id])
torigin[id][2] += 0
set_user_origin(id,torigin[id])
return PLUGIN_HANDLED;
}
public getout(id)
{
carpool[id] = 0
client_print(id,print_chat,"[CarMod] You are no longer incar with the player!")
set_user_noclip(id,0)
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255)
get_user_origin(carpool[id], torigin[id])
torigin[id][2] += 80
set_user_origin(id,torigin[id])
remove_task(id+45)
set_task(3.0,"leavecar",id)
return PLUGIN_HANDLED;
}
public leavecar(id)
{
carpooled[id] = 0
return PLUGIN_HANDLED
}
When I leave, I am teleported above the driver's head, but I constantly am flooded with