PDA

View Full Version : Porting this CSS plugin to a TF2 Jump Plugin...


duydangle
02-13-2012, 21:19
Hello you guys. I currently want to port the cP mod (http://forums.alliedmods.net/showthread.php?p=1084489) to a TF2. I used this plugin before on a bhop server, and currently I want to make a jump server. I found that the TF2 jump mode on alliedmods are reported that not work perfectly, although I didn't test it. But after a few modifications, although there are some error logs, I've got cP mod work on my TF2 Jump server with these features: no damage, save and tele works (not through class). For me that's enough, although I will have to remove some of the features specifically for CSS (give flashbang, smoke nades,...)

Right now I am have some troubles to make it save and teleport with different classes. The reason is one friend of mine, who has previous jumped in several servers, said that if there are some difficult stages, people could just change class to demoman...

Anyone can help me, I will appreciate it. Thanks...

This is the code I found useful
//-----------------------------//
// save player location method //
//-----------------------------//
public SaveClientLocation(client){
//if no valid player
if(!IsPlayerAlive(client) || GetClientTeam(client) == 1)
return;

//if plugin is enabled
if(g_bEnabled){
//if player on ground
if(GetEntDataEnt2(client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) != -1){
new whole = g_WholeCp[client];

//if player has less than limit checkpoints
if(whole < CPLIMIT){
//save some data
GetClientAbsOrigin(client,g_fPlayerCords[client][whole]);
GetClientAbsAngles(client,g_fPlayerAngles[client][whole]);

//increase counters
g_CurrentCp[client] = g_WholeCp[client];
g_WholeCp[client]++;

PrintToChat(client, "%t", "CpSaved", YELLOW,LIGHTGREEN,YELLOW,GREEN,whole+1,whole+ 1,YELLOW);

EmitSoundToClient(client,"buttons/blip1.wav",client);
TE_SetupBeamRingPoint(g_fPlayerCords[client][whole],10.0,200.0,g_BeamSpriteRing1,0,0,10,1.0,50.0 ,0.0,{255,255,255,255},0,0);
TE_SendToClient(client);
}else if(g_bRotation && whole == CPLIMIT){ //cp rotation enabled
new current = g_CurrentCp[client];

//if last slot reached
if(current+1 == CPLIMIT){
//reset to first slot
g_CurrentCp[client] = 0;
current = 0
}else{
g_CurrentCp[client]++;
current++;
}

//save some data
GetClientAbsOrigin(client,g_fPlayerCords[client][current]);
GetClientAbsAngles(client,g_fPlayerAngles[client][current]);
PrintToChat(client, "%t", "CpSaved", YELLOW,LIGHTGREEN,YELLOW,GREEN,current+1,whol e,YELLOW);

EmitSoundToClient(client,"buttons/blip1.wav",client);
TE_SetupBeamRingPoint(g_fPlayerCords[client][current],10.0,200.0,g_BeamSpriteRing1,0,0,10,1.0,50.0 ,0.0,{255,255,255,255},0,0);
TE_SendToClient(client);
}else //checkpoint limit
PrintToChat(client, "%t", "CpLimit", YELLOW,LIGHTGREEN,YELLOW,GREEN,YELLOW);
}else //not on ground
PrintToChat(client, "%t", "NotOnGround", YELLOW,LIGHTGREEN,YELLOW);
}else //disabled
PrintToChat(client, "%t", "PluginDisabled", YELLOW,LIGHTGREEN,YELLOW);
}

//---------------------//
// tele player method //
//--------------------//
public TeleClient(client,pos){
//if no valid player
if(!IsPlayerAlive(client) || GetClientTeam(client) == 1)
return;

//if plugin is enabled
if(g_bEnabled){
if(!g_bRacing[client]){
new current = g_CurrentCp[client];
new whole = g_WholeCp[client];

//if on last slot and next
if(current == whole-1 && pos == 1){
//reset to first
g_CurrentCp[client] = -1;
current = -1;
}
//if on first slot and previous
if(current == 0 && pos == -1){
//reset to last
g_CurrentCp[client] = whole;
current = whole;
}

new actual = current+pos;

//if not valid checkpoint
//if(actual < 0 || actual > whole || (g_fPlayerCords[client][actual][0] == 0.0 && g_fPlayerCords[client][actual][1] == 0.0 && g_fPlayerCords[client][actual][2] == 0.0)){
if(actual < 0 || actual > whole){
PrintToChat(client, "%t", "CpNotFound", YELLOW,LIGHTGREEN,YELLOW);
}else{ //valid
TeleportEntity(client, g_fPlayerCords[client][actual],g_fPlayerAngles[client][actual],NULL_VECTOR);
PrintToChat(client, "%t", "CpTeleported", YELLOW,LIGHTGREEN,YELLOW,GREEN,actual+1,whole ,YELLOW);
g_CurrentCp[client] += pos;

EmitSoundToClient(client,"buttons/blip1.wav",client);
TE_SetupBeamRingPoint(g_fPlayerCords[client][actual],10.0,200.0,g_BeamSpriteRing2,0,0,10,1.0,50.0 ,0.0,{255,255,255,255},0,0);
TE_SendToClient(client);
}
}else //client is on a race
PrintToChat(client, "%t", "TimerActiveProtection", YELLOW,LIGHTGREEN,YELLOW,GREEN,YELLOW);
}else //plugin disabled
PrintToChat(client, "%t", "PluginDisabled", YELLOW,LIGHTGREEN,YELLOW);
}

I think that if we can save the player's class and check if same class in teleport part, it will work.

The full code I modified: http://xtremezone.vn/jump.rar

Thanks for reading.