SA-MP Forums Archive
OnPlayerSpawn Help! [+1 Rep] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerSpawn Help! [+1 Rep] (/showthread.php?tid=593933)



OnPlayerSpawn Help! [+1 Rep] - ChristolisTV - 11.11.2015

Hello!

I want you to help me on how to create when someone spawns (OnPlayerSpawn) to check his name and if his name is for example "john", i want this specific name to tp somewhere for example. Can you please show me an example code? [+1 Rep]


Re: OnPlayerSpawn Help! [+1 Rep] - iKarim - 11.11.2015

PHP код:
public OnPlayerConnect(playerid)
{
    new 
pName[MAX_PLAYER_NAME]; //Player name's variable.
    
GetPlayerName(playeridpNamesizeof(pName))
    if(!
strcmp(pName"John"true)) // Checking if the name matches 'John'
    
{
        
SetPlayerPos(playerid0010); //Put the cords here, Just example.
    
}
    return 
1;




Re: OnPlayerSpawn Help! [+1 Rep] - ChristolisTV - 11.11.2015

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
PHP код:
public OnPlayerConnect(playerid)
{
    new 
pName[MAX_PLAYER_NAME]; //Player name's variable.
    
GetPlayerName(playeridpNamesizeof(pName))
    if(!
strcmp(pName"John"true)) // Checking if the name matches 'John'
    
{
        
SetPlayerPos(playerid0010); //Put the cords here, Just example.
    
}
    return 
1;

OK, thanks but how can i make multiple names to check? (sorry for disturbing..lol)


Re: OnPlayerSpawn Help! [+1 Rep] - iKarim - 11.11.2015

just use '||' and repeat the same strcmp function.
example.
PHP код:
public OnPlayerConnect(playerid)
{
    new 
pName[MAX_PLAYER_NAME]; //Player name's variable.
    
GetPlayerName(playeridpNamesizeof(pName))
    if(!
strcmp(pName"John"true) || !strcmp(pName"Demi"true)) // Checking if the name matches 'John' or 'Demi'
    
{
        
SetPlayerPos(playerid0010); //Put the cords here, Just example.
    
}
    return 
1;