CallRemoteFunction - What's wrong with this? -
Phil_Cutcliffe - 30.01.2014
I'm using my gamemode with a /vehiclespray command to respray the vehicle
The vehicle script is a filterscript and I'm trying to call a remote function from it so it saves the new vehicle color
Here's the GAMEMODE command and calling the remote function
pawn Код:
if (strcmp(cmd, "/vehiclespray", true) == 0 )
{
new vehicleseat = GetPlayerVehicleSeat(playerid);
if(PlayerInfo[playerid][pSprayCan] < 1)
{
SendClientMessage(playerid, COLOR_RED, "You don't have any Spray Cans!");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to do that!");
return 1;
}
if(vehicleseat != 0)
{
SendClientMessage(playerid, COLOR_RED, "You must be in the drivers seat to do that!");
return 1;
}
if(vehicleseat == 0)
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]");
return 1;
}
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]");
return 1;
}
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
CallRemoteFunction("OnVehicleRespray" "playerid", "vehicleid", "color1", "color2");
return 1;
}
}
Here's the function from the FILTERSCRIPT
pawn Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
new id = GetVehicleID(vehicleid);
if(IsValidVehicle(id))
{
VehicleColor[id][0] = color1;
VehicleColor[id][1] = color2;
SaveVehicle(id);
}
return 1;
}
Re: CallRemoteFunction - What's wrong with this? -
Pottus - 30.01.2014
Did you even read how it works?
https://sampwiki.blast.hk/wiki/CallRemoteFunction
Re: CallRemoteFunction - What's wrong with this? -
Phil_Cutcliffe - 30.01.2014
Yeah but it's really confusing me I've been coding for hours having a major brainfart I do this often lol. This is the first time I've needed to use this so I'm rather rusty. Could you help me out by maybe showing me another example I could work from?
Re: CallRemoteFunction - What's wrong with this? -
ProjectMan - 30.01.2014
pawn Код:
(strcmp(cmd, "/vehiclespray", true) == 0 )
{
new vehicleseat = GetPlayerVehicleSeat(playerid);
if(PlayerInfo[playerid][pSprayCan] < 1)
{
SendClientMessage(playerid, COLOR_RED, "You don't have any Spray Cans!");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to do that!");
return 1;
}
if(vehicleseat != 0)
{
SendClientMessage(playerid, COLOR_RED, "You must be in the drivers seat to do that!");
return 1;
}
if(vehicleseat == 0)
{
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]");
return 1;
}
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]");
return 1;
}
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
CallRemoteFunction("OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
return 1;
}
}
Re: CallRemoteFunction - What's wrong with this? -
Phil_Cutcliffe - 30.01.2014
Quote:
Originally Posted by ProjectMan
pawn Код:
(strcmp(cmd, "/vehiclespray", true) == 0 ) { new vehicleseat = GetPlayerVehicleSeat(playerid); if(PlayerInfo[playerid][pSprayCan] < 1) { SendClientMessage(playerid, COLOR_RED, "You don't have any Spray Cans!"); return 1; } if(!IsPlayerInAnyVehicle(playerid)) { SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle to do that!"); return 1; } if(vehicleseat != 0) { SendClientMessage(playerid, COLOR_RED, "You must be in the drivers seat to do that!"); return 1; } if(vehicleseat == 0) { new color1, color2; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]"); return 1; } color1 = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_RED, "USAGE: /vehiclespray [Color1] [Color2]"); return 1; } color2 = strval(tmp); ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2); CallRemoteFunction("OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2); return 1; } }
|
Ahhhhh I see how it works now. So the 4 i's don't need commas in between them no? I take it they define that each of the playerid, vehicleid etc are decimal values. Ok thanks the tutorial example was no good to me. I didn't really understand it. Now I know how to lay it out thanks.
Re: CallRemoteFunction - What's wrong with this? -
ProjectMan - 30.01.2014
Quote:
Originally Posted by Phil_Cutcliffe
Ahhhhh I see how it works now. So the 4 i's don't need commas in between them no? I take it they define that each of the playerid, vehicleid etc are decimal values. Ok thanks the tutorial example was no good to me. I didn't really understand it. Now I know how to lay it out thanks.
|
Yes, much like how you would use sscanf.
Re: CallRemoteFunction - What's wrong with this? -
Phil_Cutcliffe - 30.01.2014
Quote:
Originally Posted by ProjectMan
Yes, much like how you would use sscanf.
|
Thankyou very much +Repped