Need help :)
#1

Known problem... When you enter a vehicle you'll get crash. how can I solve it ? why is that happening :X
Thanks for help guys


Quote:

public OnPlayerStateChange(playerid, newstate, oldstate)
{

new vehicleid = GetPlayerVehicleID(playerid);
new caridx = CarSysID[vehicleid];
if(vehdata[caridx][carexists] == 0)

for(new i; i < MAX_VEHICLES; i++)
{
if(vehicleid == admincars[i] && !IsPlayerDAdmin(playerid)&& newstate == PLAYER_STATE_DRIVER)
{
new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z+7);
PlayerPlaySound(playerid, 1136, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~Admins Vehicle!",3000,4);
SendClientMessage(playerid, COLOR_KRED, "!айрк йлем мдлрс мшлб цееъ");
}
if(vehicleid == vipcars[i] && IsPlayerInAnyVehicle(playerid) && newstate == PLAYER_STATE_DRIVER && userdata[playerid][userisvip] == 0)
{
new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z+7);
PlayerPlaySound(playerid, 1136, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~VIP Vehicle!",3000,4);
SendClientMessage(playerid, COLOR_KRED, "!V.I.P айрк йлем мдлрс мшлб");
}
if(vehicleid == carshop[i] && IsPlayerInAnyVehicle(playerid) && newstate == PLAYER_STATE_DRIVER)
{
new Float, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x, y, z+7);
PlayerPlaySound(playerid, 1136, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid,"~r~Display Vehicle!",3000,4);
SendClientMessage(playerid, COLOR_KRED, "!айрк йлем мдлрс мшлб ъцевд");
}

}

// ================================= Normal =========================================== ///
if(newstate == PLAYER_STATE_DRIVER)
{
if(vehdata[caridx][carowned] == 1 && !strcmp(GetName(playerid), vehdata[caridx][carowner], true))
{
format(String,sizeof(String),"{FF9900}\"%s\" {FFFFFF}:щйвшъ аъ шлбк осев",VehNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessage(playerid,-1,String);
if(userdata[playerid][insurance] == 0) return SendClientMessage(playerid,COLOR_KRED,"/InsuranceHelp - айп мк бйиез мшлб");
if(userdata[playerid][insurance] == 1) {
format(String,sizeof(String), "{FFFFFF}.дйре шлб обеиз {FF0000}\"%s\" {FFFFFF}:шлб",VehNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
SendClientMessage(playerid,-1,String);
SendClientMessage(playerid,-1,"/Fix - мъйчеп дшлб добеиз шщен");
}
}
else if(vehdata[caridx][carowned] == 1 && strcmp(GetName(playerid), vehdata[caridx][carowner], true) && vehdata[caridx][carsetprice] != 0)
{
format(String, 256, "./BuyCar еоецт молйшд бозйш щм $%d тм оръ мшлещ шлб жд шщен %s шлб жд роца ббтмеъ дщзчп",vehdata[caridx][carsetprice], vehdata[caridx][carowner]);
SendClientMessage(playerid, COLOR_KRED, String);
}
else if(vehdata[caridx][carowned] == 1 && strcmp(GetName(playerid), vehdata[caridx][carowner], true))
{
format(String, 256, ".%s шлб жд роца ббтмеъ дщзчп", vehdata[caridx][carowner]);
SendClientMessage(playerid, COLOR_KRED, String);
}
}




if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(LastVehicleTick[playerid] == -1)
{
LastVehicleTick[playerid] = GetTickCount();
}
else
{
if( ( GetTickCount() - LastVehicleTick[playerid] ) <= 100)
{
LastVehicleWarns[playerid]++;

if(LastVehicleWarns[playerid] >= 2)
{
format(SAC_WeaponString, 120, "GC_Guard: %s has been kicked from the server (Vehicle Hacks).", GetName(playerid));
SendClientMessageToAll(COLOR_KRED, SAC_WeaponString);
SendClientMessageToAll(COLOR_YELLOW, "[Anti-Cheat] All vehicles has been respawned due to vehicle hacks being detected.");
SetTimerEx("KickPlayer",200,false,"i",playerid);
Kick(playerid);
KillTimer(respawncarstimer);
respawncarstimer = SetTimer("RespawnAllCars", 1000, 0);
}
}
}
}

LastVehicleTick[playerid] = GetTickCount();


if(newstate == PLAYER_STATE_ONFOOT)
{
SetPlayerArmedWeapon(playerid, 0);
SAC_WeaponCheck[playerid] = 0;
SAC_RealWeapCheck[playerid] = SetTimerEx("RealWeaponCheck", 1500, 0, "i", playerid);
}

if(oldstate == 2 && newstate != 2 && AntiOn[playerid] != 0 && MyVeh[playerid] > -1) return PutPlayerInVehicle(playerid,MyVeh[playerid],0);

if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
if(userdata[playerid][usercodetype] == 7 && AntiOn[playerid] == 1)
{
AntiOn[playerid] = 1;
}
}

if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
{
if(userdata[playerid][usercodetype] == 7 && AntiOn[playerid] == 1)
{
PutPlayerInVehicle(playerid, MyVeh[playerid], 0);
}
}

return 1;
}







Or // OnPlayerEnterVehicle //:
Quote:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i=1; i < MAX_VEHICLES; i++)
{
if(vehdata[i][carexists] == 0)
{
if(userdata[playerid][license] == 1) return 0;
}
else
{
if(userdata[playerid][license] == 0)
SetTimerEx("LicenseMSG",5000,0,"i",playerid);
}
return 1;
}
GetPlayerName(playerid, playername, sizeof(playername));
if(userdata[playerid][usercodetype] == 7)
{
if(IsVehicleIsBike(vehicleid)) MyVeh[playerid] = vehicleid;
}
return 1;
}
public isPlayerInArea(playerID, Float:data[4])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerID, X, Y, Z);
if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
return 1;
}
return 0;
}

Reply
#2

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i=1; i < MAX_VEHICLES; i++)
{
if(vehdata[i][carexists] == 0)
{
if(userdata[playerid][license] == 1) return 0;
}
else
{
if(userdata[playerid][license] == 0)
SetTimerEx("LicenseMSG",5000,0,"i",playerid);
}
return 1;
}
GetPlayerName(playerid, playername, sizeof(playername));
if(userdata[playerid][usercodetype] == 7)
{
if(IsVehicleIsBike(vehicleid)) MyVeh[playerid] = vehicleid;
}
return 1;
}
public isPlayerInArea(playerID, Float:data[4])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerID, X, Y, Z);
if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
return 1;
}
return 0;
}
why using return 1 when its already going in 1 at end of the onplayerentervehicle
use this.
Reply
#3

Quote:
Originally Posted by CaptainBoi
Посмотреть сообщение
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i=1; i < MAX_VEHICLES; i++)
{
if(vehdata[i][carexists] == 0)
{
if(userdata[playerid][license] == 1) return 0;
}
else
{
if(userdata[playerid][license] == 0)
SetTimerEx("LicenseMSG",5000,0,"i",playerid);
}
return 1;
}
GetPlayerName(playerid, playername, sizeof(playername));
if(userdata[playerid][usercodetype] == 7)
{
if(IsVehicleIsBike(vehicleid)) MyVeh[playerid] = vehicleid;
}
return 1;
}
public isPlayerInArea(playerID, Float:data[4])
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerID, X, Y, Z);
if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {
return 1;
}
return 0;
}
why using return 1 when its already going in 1 at end of the onplayerentervehicle
use this.
That's why I am getting crashed?
Reply
#4

Please check your indentations and post code again.
On Topic: i said to check it if that doesnot work Post here.
Reply
#5

Quote:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
for(new i=1; i < MAX_VEHICLES; i++)
{
if(vehdata[i][carexists] == 0)
{
if(userdata[playerid][license] == 1) return 0;
}
else
{
if(userdata[playerid][license] == 0)
SetTimerEx("LicenseMSG",5000,0,"i",playerid);
}
}
return 1;
}


Fixed.


the problem was in here i guess... Take a look maybe you'll agree with me.

Quote:

}
GetPlayerName(playerid, playername, sizeof(playername));
if(userdata[playerid][usercodetype] == 7)
{
if(IsVehicleIsBike(vehicleid)) MyVeh[playerid] = vehicleid;
}
return 1;
}

Reply
#6

dude as i told u that their was extra return 1; u had added okay now u removed it and its fixed done
enjoy
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)