Posts: 134
Threads: 32
Joined: Dec 2007
Reputation:
0
1. If OnPlayerRequestSpawn returns 0, is it possible through a glitch or hack to still spawn?
2. Are these both secure?
public OnPlayerRequestSpawn(playerid)
{
if(GetPVarInt(playerid, "logged_in") == 1)
{
return 1;
}
else
{
Login_Box(playerid);
return 0;
}
}
and
public OnPlayerSpawn(playerid)
{
if(GetPVarInt(playerid, "logged_in") == 1)
{
SetPlayerSpawnDetails(playerid);
return 1;
}
else
{
System_Kick(playerid, "Spawned Without Logging In");
return 0;
}
}
3. Is it necessary to have the if/else in OnPlayerSpawn?
Posts: 214
Threads: 1
Joined: May 2010
Reputation:
0
The second check in OnPlayerSpawn shouldn't be necessary anymore. OnPlayerRequestSpawn always gets called and your function seems quite safe.
Posts: 134
Threads: 32
Joined: Dec 2007
Reputation:
0
I really appreciate all of your help! One more question...
I have a custom function OnPlayerLogin...
It is called once someone logs into their account. Then it distributes all of their account variables from my MYSQL database to their PVars.
ie:
public OnPlayerLogin(playerid)
{
**all of the Pvars being set and database stuff**
if(GetPVarInt(playerid, "banned") == 1)
{
System_Ban(playerid, "Account Banned");
return 1;
}
if(GetPVarInt(playerid, "locked") == 1)
{
System_Kick(playerid, "Character Locked");
return 1;
}
**set additional pvar's and stuff***
return 1;
}
Q: Will the bolded return 1's end the function (assuming the player is locked or banned) and not continue setting the additional pvars beneath it?
Q: Hopefully it does, but should it be return 1 or return 0? Does it matter?
Posts: 214
Threads: 1
Joined: May 2010
Reputation:
0
Returns end the function at the respective line, any code below won't be executed anymore.
Whether you return 1 or 0 in custom functions doesn't matter in that case (if you do not use the return value of this function somewhere else). I prefer returning 1 as - unlike to other languages - you don't go for the phrase "I return 0 as there are 0 errors" in samp scripting anyways.
Just keep on returning 1, it's all fine.