Script: SetPlrExtraData and SetCrewExtraData can store strings

Günther Brammer 2011-05-02 23:01:19 +02:00
parent 1583ad603b
commit 177b085271
4 changed files with 10 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<func>
<title>SetCrewExtraData</title>
<category>Player</category>
<version>4.9.6.0 CR</version>
<version>4.9.6.0 CR<extversion>5.2 OC</extversion></version>
<syntax>
<rtype>any</rtype>
<params>
@ -23,7 +23,7 @@
</params>
</syntax>
<desc>With this function additional data can be saved in a crew member's file the in player. This can be used to preserve values across scenarios, for example for RPGs or highscores. If successful, the saved value is returned.</desc>
<remark>No objects or strings may be saved.</remark>
<remark>No objects or arrays may be saved.</remark>
<remark>Because all scripts use the same storage in the crew member, the name for the data should be prefixed with the scenario or object name or your developer id.</remark>
<examples>
<example>

View File

@ -6,7 +6,7 @@
<func>
<title>SetPlrExtraData</title>
<category>Player</category>
<version>4.9.1.0 GWE</version>
<version>4.9.1.0 GWE<extversion>5.2 OC</extversion></version>
<syntax>
<rtype>any</rtype>
<params>
@ -28,7 +28,7 @@
</params>
</syntax>
<desc>With this function additional data can be saved in player's file. This can be used to preserve values across scenarios, for example for RPGs or highscores. If successful, the saved value is returned.</desc>
<remark>No objects or strings may be saved.</remark>
<remark>No objects or arrays may be saved.</remark>
<remark>Because all scenarios use the same storage, the name for the data should be prefixed with the scenario name or your developer id.</remark>
<examples>
<example>

View File

@ -248,10 +248,11 @@ static C4Value FnSetCrewExtraData(C4AulContext *cthr, C4Value *strDataName_C4V,
const char *strDataName = FnStringPar(strDataName_C4V->getStr());
// valid crew with info? (for great nullpointer prevention)
if (!cthr->Obj->Info) return C4Value();
// do not allow data type C4V_String or C4V_C4Object
// do not allow data type C4V_Array or C4V_C4Object
if (Data->GetType() != C4V_Any &&
Data->GetType() != C4V_Int &&
Data->GetType() != C4V_Bool) return C4VNull;
Data->GetType() != C4V_Bool &&
Data->GetType() != C4V_String) return C4VNull;
// get pointer on info...
C4ObjectInfo *pInfo = cthr->Obj->Info;
// no name list created yet?

View File

@ -1605,10 +1605,11 @@ static C4Value FnSetPlrExtraData(C4AulContext *cthr, C4Value *iPlayer_C4V, C4Val
const char *strDataName = FnStringPar(strDataName_C4V->getStr());
// valid player? (for great nullpointer prevention)
if (!ValidPlr(iPlayer)) return C4Value();
// do not allow data type C4V_String or C4V_C4Object
// do not allow data type C4V_Array or C4V_C4Object
if (Data->GetType() != C4V_Any &&
Data->GetType() != C4V_Int &&
Data->GetType() != C4V_Bool) return C4VNull;
Data->GetType() != C4V_Bool &&
Data->GetType() != C4V_String) return C4VNull;
// get pointer on player...
C4Player* pPlayer = ::Players.Get(iPlayer);
// no name list created yet?