Question about SetSpawnInfo
#1

Hey guys
I was wondering about something for future use
If I set someone's spawn info using the function and then spawn him using SpawnPlayer
Does the SpawnPlayer resets the "Spawn Info" so I have to Set the info again ?
or is it until I change it again
Reply
#2

That's a good question. I didn't know, so I went ahead and tested it for you. It seems like the data set with SetSpawnInfo is being remembered until changed. This means that if you don't call SetSpawnInfo somewhere else, that you will always spawn back with the data you entered first.

Test code:
PHP код:
#include <a_samp>
main() { }
public 
OnGameModeInit() {
    return 
true;
}
public 
OnGameModeExit() {
    return 
true;
}
public 
OnPlayerConnect(playerid) {
    
Player_SetSpawnInfo(playerid);
    return 
true;
}
Player_SetSpawnInfo(playerid) {
    
SetSpawnInfo(playerid055.05.05.0180.0000000);
    
SpawnPlayer(playerid);
    return 
true;
}
public 
OnPlayerCommandText(playeridcmdtext[]) {
    if(!
strcmp(cmdtext"/kill"true)) {
        
SpawnPlayer(playerid);
        return 
true;
    }
    return 
false;

Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
That's a good question. I didn't know, so I went ahead and tested it for you. It seems like the data set with SetSpawnInfo is being remembered until changed. This means that if you don't call SetSpawnInfo somewhere else, that you will always spawn back with the data you entered first.

Test code:
PHP код:
#include <a_samp>
main() { }
public 
OnGameModeInit() {
    return 
true;
}
public 
OnGameModeExit() {
    return 
true;
}
public 
OnPlayerConnect(playerid) {
    
Player_SetSpawnInfo(playerid);
    return 
true;
}
Player_SetSpawnInfo(playerid) {
    
SetSpawnInfo(playerid055.05.05.0180.0000000);
    
SpawnPlayer(playerid);
    return 
true;
}
public 
OnPlayerCommandText(playeridcmdtext[]) {
    if(!
strcmp(cmdtext"/kill"true)) {
        
SpawnPlayer(playerid);
        return 
true;
    }
    return 
false;

Thanks
Anyways, I am also going to test if spawning under F4 (Class selection return) resets it, although I can only do it tomorrow, may you if you have the time ?
Reply
#4

The way you spawn a player is irrelevant.

Test code:
PHP код:
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS    1
new class_id[MAX_PLAYERS];
main() { }
public 
OnGameModeInit() {
    
AddPlayerClass(05.05.05.0180.0000000);
    
AddPlayerClass(510.05.05.0180.0000000);
    
AddPlayerClass(1013.05.05.0180.0000000);
    
AddPlayerClass(1515.05.05.0180.0000000);
    return 
true;
}
public 
OnGameModeExit() {
    return 
true;
}
public 
OnPlayerConnect(playerid) {
    return 
true;
}
public 
OnPlayerRequestClass(playeridclassid) {
    
class_id[playerid] = classid;
    return 
true;
}
public 
OnPlayerRequestSpawn(playerid) {
    if(
class_id[playerid] == 0) {
        
// CJ
        
SetSpawnInfo(playerid0030.05.05.0180.0000000);
    }
    
SpawnPlayer(playerid);
    return 
true;
}
public 
OnPlayerCommandText(playeridcmdtext[]) {
    if(!
strcmp(cmdtext"/kill"true)) {
        
SetPlayerHealth(playerid0.0);
        return 
true;
    }
    if(!
strcmp(cmdtext"forceselection"true)) {
        
ForceClassSelection(playerid);
        
TogglePlayerSpectating(playeridtrue);
        
TogglePlayerSpectating(playeridfalse);
        return 
true;
    }
    return 
false;

I first spawned as CJ to set the spawn info. I then pressed F4 and killed myself. I picked a different class and spawned on the same location as specified in SetSpawnInfo.
Reply
#5

By reading the wiki, you could have answered your own question:
Quote:

This function can be used to change the spawn information of a specific player. It allows you to automatically set someone's spawn weapons, their team, skin and spawn position, normally used in case of minigames or automatic-spawn systems. This function is more crash-safe then using SetPlayerSkin in OnPlayerSpawn and/or OnPlayerRequestClass, even though this has been fixed in 0.2.

Reply
#6

Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)