You're doing an assignment operation (A = B) instead of a comparison operation (A == B) in this
if statement:
Code:
if(checkpoint = true)
{
TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
}
else
{
PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
}
You are also failing to index the checkpoint array, but I believe, from the code you posted, you actually want to be checking the tele_saved array not the checkpoint array - the fixed code would be:
Code:
if(tele_saved[client] == 1)
{
TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
}
else
{
PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
}
Also, it would probably be a good idea to tag the tele_saved array as 'bool:' and populate it with falses by default:
Code:
new bool:tele_saved[MAXPLAYERS+1] = { false, ... };
Then you can change this line for type clarity:
Code:
tele_saved[client] = true;
The last two points don't really affect how the code will function but are merely good practice for maintaining clarity on what the various arrays are storing (in this case a boolean).
The complete example would then be:
Code:
new bool:tele_saved[MAXPLAYERS+1] = { false, ... };
new Float:checkpoint[MAXPLAYERS+1][3];
RegConsoleCmd("sm_save", Command_save, "Saving a Checkpoint on The Client Position.");
RegConsoleCmd("sm_tele", Command_tele, "Teleport to your Saved Checkpoint.");
RegConsoleCmd("sm_s", Command_save, "Saving a Checkpoint on The Client Position.");
RegConsoleCmd("sm_t", Command_tele, "Teleport to your Saved Checkpoint.");
public Action:Command_save(client, args)
{
GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint[client]);
tele_saved[client] = true;
PrintToChat(client, "\x04[SM]\x01 CheckPoint Saved.");
}
public Action:Command_tele(client, args)
{
if(tele_saved[client])
{
TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint.");
}
else
{
PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint First, Type !s/!save for that.)");
}
}